Skip to content

Conversation

kanmanus
Copy link
Contributor

A fixed header will hide the top part of your content when you click on the link, so I think we need an offset option to make the scrolling function to be more correct.

@@ -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

@jljsj33
Copy link
Member

jljsj33 commented Oct 21, 2016

Thanks.. I would have wanted to add this offset.

@jljsj33
Copy link
Member

jljsj33 commented Oct 21, 2016

#11

@jljsj33 jljsj33 merged commit c25c183 into react-component:master Oct 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants