react-scroll-manager icon indicating copy to clipboard operation
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

Open mixalbl4-127 opened this issue 4 years ago • 5 comments

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

mixalbl4-127 avatar Dec 22 '20 10:12 mixalbl4-127

@trevorr please check pull :)

mixalbl4-127 avatar Dec 22 '20 10:12 mixalbl4-127

Could you provide a test or example that reproduces this issue?

trevorr avatar Dec 23 '20 16:12 trevorr

example of bug: https://codesandbox.io/s/little-snowflake-cdh24 Steps:

  1. Click "More"
  2. Click "More"
  3. Click "Reload"
  4. Click "More"
  5. Try to scroll page UP Peek 2020-12-24 14-00 @trevorr

mixalbl4-127 avatar Dec 24 '20 12:12 mixalbl4-127

@trevorr hi :) check please

mixalbl4-127 avatar Jan 28 '21 09:01 mixalbl4-127

@trevorr any news?

mixalbl4-127 avatar Apr 05 '21 09:04 mixalbl4-127