react-scroll-manager
react-scroll-manager copied to clipboard
When page was resized (the height has become smaller, eg: lazy load items or lanscape mod on mobile phone), will scroll hundreds of times before timeout
I had problem when page with button "more" increased height till 5000 - 10 000 pixed, you clicked to some Item at bottom (scrollTop === 10 000), and you press "back", height of page becomes original (~1 000px) without new items (because button more was not clicked again). In this case, react scroll manager going to scoll hundreds of times (on any observer event) but unsuccessful, because it scroll to 1 000px and 10 000px is unreachable. At this time user try to scroll UP, he will be scrolled to bottom now, till timeout
. A very nasty bug.
In this regard, I changed the logic of the library's behavior. Now, before attempting to scroll the page, we calculate whether this attempt will be successful, if it cannot succeed - it don't even try to do this.
But now I saw situations, when page has a little bit dynamic height (+- 5px because of example: :hover { border: 2px solid red; }
), for this case Ive added new prop
blockSizeTolerance`
I've removed Skipping save due to deferred scroll of ${scrollKey}
bacause no need it anymore, _savePosition
will not have fake calls from attemptScroll
because now we execute window.scrollTo
only once, when 100% have reachable scroll position.
Pull: https://github.com/trevorr/react-scroll-manager/pull/15
@trevorr please check pull :)
Could you provide a test or example that reproduces this issue?
example of bug: https://codesandbox.io/s/little-snowflake-cdh24 Steps:
- Click "More"
- Click "More"
- Click "Reload"
- Click "More"
- Try to scroll page UP
@trevorr
@trevorr hi :) check please
@trevorr any news?