Repository navigation
Dispatch paired momentum scroll events for animated programmatic scrolls - #60162
Open
Abbondanzo wants to merge 1 commit into
Open
Abbondanzo wants to merge 1 commit into
Abbondanzo wants to merge 1 commit into
Conversation
Summary: On iOS, an animated `scrollTo`/`scrollToEnd` dispatched `onMomentumScrollEnd` without a preceding `onMomentumScrollBegin`, and a non-animated one dispatched a lone `onMomentumScrollEnd`. Android dispatches a begin/end pair for animated programmatic scrolls and nothing for non-animated ones. An earlier attempt dispatched `onMomentumScrollBegin` after starting the animation. When UIKit finished the animation synchronously, or never reported its end, the begin event arrived after its end event or was never matched. `ScrollView` treats a begin newer than the last end as "still animating" and captures every touch, so its children stopped responding. Behind the `fixProgrammaticScrollMomentumEventsIOS` feature flag (off by default, on for the OSS canary release level), track an in-flight animated programmatic scroll and guarantee ordering and pairing: - Dispatch `onMomentumScrollBegin` before calling `setContentOffset:animated:`. - Dispatch `onMomentumScrollEnd` when the animation ends, when UIKit applies the offset without animating (no window, or offset applied immediately), when a drag interrupts the animation, when the view leaves the window, or from a fallback one second later if UIKit never reports the end. - Non-animated scrolls, and animated `zoomToRect`, dispatch neither event. With the flag off, behavior is unchanged. Changelog: [iOS][Added] - `fixProgrammaticScrollMomentumEventsIOS` feature flag: `onMomentumScrollBegin` and `onMomentumScrollEnd` fire as a pair for animated `scrollTo`/`scrollToEnd`, and neither fires for non-animated scrolls Reviewed By: andrewdacenko Differential Revision: D131264148
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D131264148. |
andrewdacenko
approved these changes
Nov 19, 2026
andrewdacenko
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
On iOS, an animated
scrollTo/scrollToEnddispatchedonMomentumScrollEndwithout a precedingonMomentumScrollBegin, and a non-animated one dispatched a loneonMomentumScrollEnd. Android dispatches a begin/end pair for animated programmatic scrolls and nothing for non-animated ones.An earlier attempt dispatched
onMomentumScrollBeginafter starting the animation. When UIKit finished the animation synchronously, or never reported its end, the begin event arrived after its end event or was never matched.ScrollViewtreats a begin newer than the last end as "still animating" and captures every touch, so its children stopped responding.Behind the
fixProgrammaticScrollMomentumEventsIOSfeature flag (off by default, on for the OSS canary release level), track an in-flight animated programmatic scroll and guarantee ordering and pairing:onMomentumScrollBeginbefore callingsetContentOffset:animated:.onMomentumScrollEndwhen the animation ends, when UIKit applies the offset without animating (no window, or offset applied immediately), when a drag interrupts the animation, when the view leaves the window, or from a fallback one second later if UIKit never reports the end.zoomToRect, dispatch neither event.With the flag off, behavior is unchanged.
Changelog:
[iOS][Added] -
fixProgrammaticScrollMomentumEventsIOSfeature flag:onMomentumScrollBeginandonMomentumScrollEndfire as a pair for animatedscrollTo/scrollToEnd, and neither fires for non-animated scrollsReviewed By: andrewdacenko
Differential Revision: D131264148