-
-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling scrollToItem() or scrollTo() triggers onScroll (callback) event twice, with inconsistent scrollUpdateWasRequestedProperty #228
Comments
I don't think I have the time to look into this. If you'd like to submit a PR with unit tests I'll be happy to review and consider it. |
Hey @bvaughn. The property So for react-window/src/createGridComponent.js Lines 738 to 741 in c71baad
The rounded value is different from the double one. It triggers a setState and thus call the callback. On |
Thanks for sharing your findings, @telaoumatenyanis. Seems like some rounding may be necessary then. PRs welcome for this. |
Seems I have somewhat similar issue in firefox, but when using FixedSizeList. Can I help this somehow? |
FYI I have a workaround that seems to work in my application. I created an
|
Repro steps:
prop
foronScroll
toVariableSizeGrid
component.scrollToItem()
orscrollTo()
scrollUpdateWasRequestedProperty
istrue
.scrollUpdateWasRequestedProperty
isfalse
.Here is a sandbox with the repro:
https://codesandbox.io/s/4lq8xqwn14
scrollToDecimalPX
button (using scrollTo with fractional part on PX value (500.34))Additional findings:
scrollTop
property inscrollTo
function always repro (two calls toonScroll
callback).scrollTop
property inscrollTo
function makes two calls toonScroll
but at least one out of ten times, it only calls it once.ScrollToItem
withalign: auto
oralign: start
always callsonScroll
once (as expected).ScrollToItem
withalign: end
oralign: center
always callsonScroll
twice.ScrollToItem
withalign: smart
callsonScroll
once or twice.Seems like the position in which we are scrolling to has an important role into whether
onScroll
gets called twice or once.For context, I am trying to sync react-window
VariableSizeGrid
with another element B. I am trying to ignore theonScroll
callback, but can't achieve that because of this.The text was updated successfully, but these errors were encountered: