Skip to content

Commit bc810e5

Browse files
Abbondanzofacebook-github-bot
authored andcommitted
Only apply event throttling to scroll view events (facebook#48712)
Summary: Pull Request resolved: facebook#48712 Currently, all scroll events can be throttled by the `scrollEventThrottle` value when the intention is only to throttle `onScroll` calls. As a result, the scroll view helper unintentionally drops events unrelated to scrolling, like momentum begin/end. It's imperative that these momentum events dispatch so the scroll view does not lock itself in an "animated" state on the JS side; if locked in an animation state, children of the scroll view will not receive touch events. This can happen when the throttle is sufficiently high and momentum scrolling completes before the throttle time has elapsed. Changelog: [Android][Fixed] - Scroll view throttle no longer impacts events other than `onScroll` Reviewed By: javache, rshest Differential Revision: D68234045 fbshipit-source-id: d5c11412d3f273811a45e6f61af08d3fcf9f61d5
1 parent 166347e commit bc810e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public object ReactScrollViewHelper {
108108
// Throttle the scroll event if scrollEventThrottle is set to be equal or more than 17 ms.
109109
// We limit the delta to 17ms so that small throttles intended to enable 60fps updates will not
110110
// inadvertently filter out any scroll events.
111-
if (scrollView.scrollEventThrottle >= Math.max(17, now - scrollView.lastScrollDispatchTime)) {
111+
if (scrollEventType == ScrollEventType.SCROLL &&
112+
scrollView.scrollEventThrottle >= Math.max(17, now - scrollView.lastScrollDispatchTime)) {
112113
// Scroll events are throttled.
113114
return
114115
}
@@ -138,7 +139,9 @@ public object ReactScrollViewHelper {
138139
contentView.height,
139140
scrollView.width,
140141
scrollView.height))
141-
scrollView.lastScrollDispatchTime = now
142+
if (scrollEventType == ScrollEventType.SCROLL) {
143+
scrollView.lastScrollDispatchTime = now
144+
}
142145
}
143146
}
144147

0 commit comments

Comments
 (0)