0

As per the react-scroll readme, we have to pass in

to="target"

props to help in tracking the element and also to navigate to the element when clicked.

We have a use-case where we need to make the link active some pixels before the element reaches the top. And, when clicked on the link, it should navigate to where the start of the element.

I tried setting

offset={-200}

to negative values. It solves the use-case of making the link active even before the element reaches the top. But, when clicked on the link, it navigates to the element with set offset, meaning, not bringing the element to the top and adding the offset pixel.

How can we customise these two behaviours? In case of click, the navigation point should be the start of element and in case of scrolling the link should become active even before the start of element is reached.

I think, if we can stop the navigate to behaviour of Link somehow then we can use onClink callback function to scroll to an element start while keeping the scrolling with mouse behaviour working with desired offset.

Please let me know if you have a way out. Thanks in advance!!

plffy
  • 21
  • 3

0 Answers0