Commit 8fea848
committed
fix: prevent unbounded scroll-event recursion while scrollable is locked
`handleOnScroll` issued `scrollTo(scrollableRef, 0, lockPosition, false)` on
every scroll event while the scrollable was LOCKED, including when the
scrollable was already resting at `lockPosition`.
`scrollTo` still drives the underlying scroll view, which emits another scroll
event, which re-enters `handleOnScroll`, which calls `scrollTo` again. Once the
offset has settled there is nothing left to break the cycle, so it recurses
until the JS stack overflows with `RangeError: Maximum call stack size
exceeded`, with the stack alternating between Reanimated's
`useAnimatedScrollHandler` and this handler.
Skip the `scrollTo` when the scrollable is already at the lock position, within
a small epsilon to tolerate the sub-pixel offsets reported during scrolling.
`scrollableContentOffsetY.value` is still assigned unconditionally, so the
shared value is unchanged.
`handleOnEndDrag` and `handleOnMomentumEnd` contain the same unconditional
`scrollTo`, but they fire once per gesture rather than on every scroll event, so
they cannot feed themselves. Left untouched to keep this fix minimal.1 parent 9bfbeb5 commit 8fea848
1 file changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
58 | | - | |
59 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
| |||
0 commit comments