Skip to content

Commit

Permalink
Reenable scrollEventThrottle prop for ScrollView and HorizontalScroll…
Browse files Browse the repository at this point in the history
…View (#38475)

Summary:
Pull Request resolved: #38475

We added `scrollEventThrottle` for android in D35735978, but the experiment was never executed and the flag got removed in D39449184.

Since the same feature is on iOS and the implementation here is the same to iOS (https://fburl.com/code/htcuhq4w), it should be safe to support.

Changelog:
[Android][Add] - Add scrollEventThrottle prop support for android

Reviewed By: cortinico

Differential Revision: D47492259

fbshipit-source-id: 09a2bead652bfef4a2c70b996cf66f6983604db2
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Jul 17, 2023
1 parent ab3c00d commit 777934e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ private static <T extends ViewGroup & HasScrollEventThrottle> void emitScrollEve
private static <T extends ViewGroup & HasScrollEventThrottle> void emitScrollEvent(
T scrollView, ScrollEventType scrollEventType, float xVelocity, float yVelocity) {
long now = System.currentTimeMillis();
// Throttle the scroll event if scrollEventThrottle is set to be equal or more than 17 ms.
// We limit the delta to 17ms so that small throttles intended to enable 60fps updates will not
// inadvertently filter out any scroll events.
if (scrollView.getScrollEventThrottle()
>= Math.max(17, now - scrollView.getLastScrollDispatchTime())) {
// Scroll events are throttled.
return;
}

View contentView = scrollView.getChildAt(0);

if (contentView == null) {
Expand Down

0 comments on commit 777934e

Please sign in to comment.