Closed DevinFrenze closed 8 months ago
@bvaughn sorry to ping you, but if you have a moment to glance at this and let me know if you think it's a reasonable change i would appreciate it. i'm using react-window in a project and would much rather get this change in and use the main repo than be using a fork indefinitely.
and for what it's worth i have tested this some amount and believe that it works as expected.
@bvaughn i'm requesting your review here. let me know if there's someone else i should reach out to for review.
I tested it in a project that I'm developing and it works well there, and it doesn't change behavior when using react-window left-to-right. Of course, there may be edge cases I don't know about.
That's fair. Okay!
@DevinFrenze Please check 1.8.10 (just published) and confirm the fix?
@bvaughn it appears to be working well ! thanks for merging
No problem. Thanks for verifying!
To determine the
scrollDirection
in the_onScrollHorizontal
method it compares the previous state'sscrollOffset
with the currentscrollLeft
value of the target. For browsers whose "RTLOffsetType" is "negative", this results in thescrollDirection
being set to "backward".The
scrollOffset
state value has been converted to a positive number or zero, and thescrollLeft
value of the target (when "RTLOffsetType" is "negative") is a negative number. When comparingprevState.scrollOffset < scrollLeft
it is always false because a positive value or zero is never greater than a negative value.Proposed fix: compare
prevState.scrollOffset < scrollOffset
becausescrollOffset
has already been transformed in the same way thatprevState.scrollOffset
was transformed.This pull request is intended to address this bug https://github.com/bvaughn/react-window/issues/689.