snapper
snapper copied to clipboard
Allow configuring the minimum velocity to scroll past an item
The documentation states:
decayAnimationSpec is the main spec used for flinging, and is used when the fling has enough velocity to scroll past the current item.
However, how do you actually configure what is 'enough' velocity? I've noticed that the default velocity doesn't fit my needs very well. Arpit Shukla described this very well 10 months ago:
Sometimes I gently swipe to the left or right and expect that I will move to the next page, but that doesn't happen, the page moves a little and then comes back. Then I realize that I need to put more effort and swipe a little more :sweat_smile:. I was thinking if it is possible to change that threshold velocity which is required to switch pages. I checked few other apps which provide a pager with a tab layout and there I can change pages with the slightest swipe.
Attaching a video to give more context to the behavior I was referring to.
https://user-images.githubusercontent.com/25990014/192085480-0d8cf1a2-4adb-4ad0-b04b-64f11eb8ee98.mp4
Perhaps it is configurable, but I cannot find how.
It's not a configurable velocity value as such. We calculate the distance which the users velocity would provide, and then either use that if it reaches the 'next' page, or switch to a 'snap'.
https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt#L254
What you're asking for can likely be implemented via the snapIndex
parameter. Although we don't currently pass in the velocity.
I see, but it doesn't seem like I can get the behavior I want without taking the velocity into account. So would you consider passing in the velocity? The idea is to allow switching page even if the actual distance the item would have passed is very small, as long as there is some small velocity to the user's swipe.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.