Skip to content

Commit c25c183

Browse files
authored
Merge pull request #12 from kanmanus/master
Add an offset property
2 parents e27e071 + fc54d19 commit c25c183

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

examples/link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class Demo extends React.Component {
4343
<p>Ant Motion</p>
4444
</div>
4545
<div className="nav-wap">
46-
<Link className="nav-list" location="page0"
46+
<Link className="nav-list" location="page0" offset={-58}
4747
onFocus={this.onFocus.bind(this)}
4848
>
4949
Example
5050
</Link>
51-
<Link className="nav-list" location="page1"
51+
<Link className="nav-list" location="page1" offset={-58}
5252
onFocus={this.onFocus.bind(this)}
5353
>
5454
Example2

src/ScrollLink.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ScrollLink extends React.Component {
5050
const elementDom = mapped.get(this.props.location);
5151
const elementRect = elementDom.getBoundingClientRect();
5252
this.scrollTop = currentScrollTop();
53-
const toTop = Math.round(elementRect.top) - Math.round(docRect.top);
53+
const toTop = Math.round(elementRect.top) - Math.round(docRect.top) + Math.round(this.props.offset?this.props.offset:0);
5454
this.toTop = this.props.toShowHeight ?
5555
toTop - transformArguments(this.props.showHeightActive)[0] : toTop;
5656
this.initTime = Date.now();

0 commit comments

Comments
 (0)