Skip to content

Commit

Permalink
Converge iOS oldarch scrollEventThrottle behavior (#41695)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41695

When I went to update documentation, I kinda internalized how inconsistent the API is if we don't change iOS Paper.

The potential for breaks is if an iOS-specific component ignores a warning, and uses `onScroll` without `scrollEventThrottle`, then relies on `onScroll` only being called once.

It didn't seem like we hit this scenario in practice when migrating Fabric ComponentView behavior, and components will need to support it in new arch anyway, so this change takes the less conservative option of unifying the behavior everywhere.

Changelog:
[iOS][Changed] - scrollEventThrottle no longer needs to be set for continuous scroll events

Reviewed By: cipolleschi

Differential Revision: D51647202

fbshipit-source-id: e2a57f3501b9096e4033cb198bbc214d53e9913c
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Nov 29, 2023
1 parent c0375b8 commit 10b3e0e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/react-native/React/Views/ScrollView/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
* We limit the delta to 17ms so that small throttles intended to enable 60fps updates will not
* inadvertently filter out any scroll events.
*/
if (_allowNextScrollNoMatterWhat ||
(_scrollEventThrottle > 0 && _scrollEventThrottle < MAX(0.017, now - _lastScrollDispatchTime))) {
if (_allowNextScrollNoMatterWhat || (_scrollEventThrottle < MAX(0.017, now - _lastScrollDispatchTime))) {
RCT_SEND_SCROLL_EVENT(onScroll, nil);
// Update dispatch time
_lastScrollDispatchTime = now;
Expand Down

0 comments on commit 10b3e0e

Please sign in to comment.