Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to linear initial velocity if there's not enough samples for inertia #14961

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

emmauss
Copy link
Contributor

@emmauss emmauss commented Mar 13, 2024

What does the pull request do?

Fallbacks to linear scroll velocity if not enough touchpoints have been registered in a swipe for polynomial computation of inertia.
This also adds a touch point at pointer press to the velocity tracker to ensure start and end points of the swipe are accounted for in the tracker.

What is the current behavior?

Some mobile os and devices have reduced touch polling rate when no activity is detected on screen, or as a power saving measure. Because of this, a flick on the screen could be faster than the os can send event that, our tracker would only register 1 or 2 pointer move events. With so few points being register in that gesture, the tracker returns 0 for inertia, even though the user has completed a swipe.

What is the updated/expected behavior with this PR?

A quick flick on a touch screen will be detected as a scroll swipe.

How was the solution implemented (if it's not obvious)?

Since we are guaranteed a PointerPressed if a user touches the screen, we register that point as the first point(0,0) in the tracker. If a swipe is done, this will add another point to the tracker on PointerMoved. If no more pointer move event are sent, we have at least 2 points to calculate the velocity of the fling when the pointer is released.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #14919

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0046159-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Mar 14, 2024
@jmacato jmacato added this pull request to the merge queue Mar 14, 2024
Merged via the queue into master with commit eca012e Mar 14, 2024
7 checks passed
@jmacato jmacato deleted the linear_scroll_inertia branch March 14, 2024 08:24
@maxkatz6 maxkatz6 added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScrollViewer Inertia not working on Android/iOS
4 participants