Smarter scroll height for 'variable' mode
See original GitHub issueOn mobile browsers the scrolling is decoupled from the scroll event to maintain 60fps, so in uniform
mode it’s important to have the threshold
set pretty high (400-1200 depending on the height of rows). Still, if the user scrolls very fast in uniform
mode they will scroll faster then the content can be rendered and they’ll see a blank screen until it catches up - not really a big deal.
However in variable
mode the height of the scroll is set dynamically as you scroll so scrolling down quickly causes the scrolling to “hit a false bottom” which stops the inertial scrolling - not good. Using an itemSizeGetter
would fix the problem but in our case the dynamic height is due to text wrapping so we don’t know the height ahead of time.
So, we need a larger scroll height sooner.
Here’s my idea: add a option minimumRowHeight
and add the minimum heights of the remaining rows (the ones with unknown heights) to the total scroll height. As you near the bottom of the scroll there is still a chance of “hitting a false bottom” but it will be much better near the top.
As an alternative, we could average the known row heights and extrapolate that to the remaining rows. This has a chance of over-estimate the scroll height but I’m not sure that’s a very bad thing since it would become more accurate as you get closer to the bottom.
I’m willing to land a pull request for this if you all think it’s a good idea. Thoughts and suggestions?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (7 by maintainers)
Top GitHub Comments
I think exposing an
itemSizeEstimator
function would be the most flexible. It would allow you to return a constant if you just want to set some minimum size or do an average of known elements as well.Good point. As long as estimated values don’t get into the cache I don’t think there’s any issues with this.