react-scroll icon indicating copy to clipboard operation
react-scroll copied to clipboard

Offset doesn't work when newly navigating page with hash

Open brightpixels opened this issue 5 years ago • 3 comments

Hello,

Demo: https://6vk5zm231k.codesandbox.io/

My page has a fixed header and offset is equal to its height, which works when clicking around within the page.

However if I navigate to the page with a hash (https://6vk5zm231k.codesandbox.io/#home, https://6vk5zm231k.codesandbox.io/#about, etc), I land on the section without the offset.

Any suggestions how to deal with this?

brightpixels avatar Mar 08 '19 19:03 brightpixels

Same problem here on version 1.7.11. Any suggestions?

willianrod avatar May 02 '19 12:05 willianrod

Any suggestions?

iknox27 avatar Nov 22 '19 14:11 iknox27

@brightpixels @willianrod @iknox27 You should use the CSS property scroll-margin-top for that. Works in all browsers, also without the react-scroll lib.

It would however be perfect if react-scroll would also respect those scroll margins so we wouldn't need to set a manual offset at all.

willemmulder avatar Apr 06 '22 13:04 willemmulder