Skip to content

Improve fling gestures on iOS#2851

Open
ASalavei wants to merge 5 commits intojb-mainfrom
andrei.salavei/improve-fling
Open

Improve fling gestures on iOS#2851
ASalavei wants to merge 5 commits intojb-mainfrom
andrei.salavei/improve-fling

Conversation

@ASalavei
Copy link

Move WebVelocityTracker1D to the skiko source set and rename it to the PointerVelocityTracker1D.
Add preventReversedPointerMovements option that prevents velocity tracker from returning velocity with the opposite direction to the general scroll direction.

Fixes https://youtrack.jetbrains.com/issue/CMP-9297/Fling-gestures-not-working-correctly-in-LazyColumn-on-iOS.

Release Notes

Fixes - iOS

  • Fix the scrolling inertia issue when performing short scroll gestures.
  • Fix an issue where a fling may occur unexpectedly when lifting a finger.

Removed unnecessary adjustment logic for sample count.
@ASalavei ASalavei requested a review from terrakok March 12, 2026 15:57
Comment on lines +156 to +161
if (dataPoints[sampleCount - 1] < dataPoints[0] && velocity < 0) {
return 0f
}
if (dataPoints[sampleCount - 1] > dataPoints[0] && velocity > 0) {
return 0f
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a wrong logic: it is a normal situation when user does two-directional gesture by their intent. We need to detect only one point mistakes (as you showed).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I still think we don't need to do that at all

Copy link
Author

@ASalavei ASalavei Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The investigation showed that fixing the "one point mistake" cannot fix the expected behavior of the gesture. There are several reasons: It can be more then one point the goes on the opposite direction from the gesture direction and on 120 fps the density of events is higher (or very low in case of lags) - this approach cannot be applied in such cases.

The goal of this MR to align behavior between native iOS and Compose scrolls. Tests show that current logic helps more closely mimic the iOS scrolling experience. We can either make this behavior multiplatform or move it to the iOS codebase.
My vote here for Multiplatform solution: scroll behavior for browsers on iOS also need to be aligned with iOS experience.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you implement a pure swift app with a scroll view + touch points tracking and show how it works on iOS?

@ASalavei ASalavei requested a review from terrakok March 13, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants