Scrolling up doesn't work with scrollMode: if-needed
icd2k3 opened this issue Β· comments
π hey there,
After some investigation of an issue posted in react-scroll-into-view-if-needed
here. It looks as though there is a bug with the following behavior:
- scrolling up to a target block with scrollMode: 'if-needed'.
I setup this codesandbox to demonstrate: https://codesandbox.io/s/l4w26w2jz7
(note: it is in React, but I'd be happy to setup an html/css only one soon if it helps)
In this example, with scrollMode set to 'always', scroll to the bottom of the page and click this button at the bottom:
Notice that it scrolls up to the target as expected
Now, switch to 'if-needed' and notice the button does not scroll up to the target.
I'm happy to dig deeper in the near future and submit a PR if I can find the problem, but in the meantime just wanted to document it here for visibility.
Thanks for your work on this package!
Hey thanks for the detailed report! I am on the go today but I will circle back in around 10 hours and have a go at it π
The flaw is probably too simplistic logic here: https://github.com/stipsan/scroll-into-view-if-needed/blob/73e7d76ab7a1e678a47f3c63a0452a3e1b96f6a5/src/compute.ts#L256-L273
π This issue has been resolved in version 2.2.5 π
The release is available on:
Your semantic-release bot π¦π
Sweet! Thanks for the timely fix @stipsan