Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class Demo extends React.Component {
<p>Ant Motion</p>
</div>
<div className="nav-wap">
<Link className="nav-list" location="page0"
<Link className="nav-list" location="page0" offset={-58}
onFocus={this.onFocus.bind(this)}
>
Example
</Link>
<Link className="nav-list" location="page1"
<Link className="nav-list" location="page1" offset={-58}
onFocus={this.onFocus.bind(this)}
>
Example2
Expand Down
2 changes: 1 addition & 1 deletion src/ScrollLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ScrollLink extends React.Component {
const elementDom = mapped.get(this.props.location);
const elementRect = elementDom.getBoundingClientRect();
this.scrollTop = currentScrollTop();
const toTop = Math.round(elementRect.top) - Math.round(docRect.top);
const toTop = Math.round(elementRect.top) - Math.round(docRect.top) + Math.round(this.props.offset?this.props.offset:0);
Copy link
Member

@jljsj33 jljsj33 Oct 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> + this.props.offsetTop

defaultProps => offsetTop: 0

this.toTop = this.props.toShowHeight ?
toTop - transformArguments(this.props.showHeightActive)[0] : toTop;
this.initTime = Date.now();
Expand Down