Skip to content

Commit 8b387f7

Browse files
committed
fix offsetTop is negative
1 parent 014eee0 commit 8b387f7

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" offsetTop={-58}
46+
<Link className="nav-list" location="page0"
4747
onFocus={this.onFocus.bind(this)}
4848
>
4949
Example
5050
</Link>
51-
<Link className="nav-list" location="page1" offsetTop={-58}
51+
<Link className="nav-list" location="page1" offsetTop={158}
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
@@ -45,7 +45,7 @@ class ScrollLink extends React.Component {
4545
const elementDom = mapped.get(this.props.location);
4646
const elementRect = elementDom.getBoundingClientRect();
4747
this.scrollTop = currentScrollTop();
48-
const toTop = Math.round(elementRect.top) - Math.round(docRect.top) + this.props.offsetTop;
48+
const toTop = Math.round(elementRect.top) - Math.round(docRect.top) - this.props.offsetTop;
4949
this.toTop = this.props.toShowHeight ?
5050
toTop - transformArguments(this.props.showHeightActive)[0] : toTop;
5151
this.initTime = Date.now();

0 commit comments

Comments
 (0)