diff --git a/examples/link.js b/examples/link.js index df2963d..ca4fea1 100644 --- a/examples/link.js +++ b/examples/link.js @@ -43,12 +43,12 @@ class Demo extends React.Component {

Ant Motion

- Example - Example2 diff --git a/src/ScrollLink.jsx b/src/ScrollLink.jsx index f796f9c..e33e9a6 100644 --- a/src/ScrollLink.jsx +++ b/src/ScrollLink.jsx @@ -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); this.toTop = this.props.toShowHeight ? toTop - transformArguments(this.props.showHeightActive)[0] : toTop; this.initTime = Date.now();