Short Answer
Disable overscroll
CompositionLocalProvider(
LocalOverscrollConfiguration provides null
) {
ViewPager()
}
Long Answer
I believe it's an issue with SnappingFlingBehavior
that's used in Pager.kt
I ran into the same issue, I couldn't find an answer to this but after looking into the source for Scrollable.kt
in the onDragStopped()
function we can see this check at the top
val preOverscrollConsumed =
if (overscrollEffect != null && overscrollEffect.isEnabled) {
overscrollEffect.consumePreFling(axisVelocity.toVelocity()).toFloat()
} else {
0f
}
If the overscroll is enabled -- which is the bounce like effect you're seeing at the beginning/end of a list and in the case of quick scrolling on the same item, it takes away from the velocity
.
This results in the implementation of SnappingFlingBehavior.performFling()
and the internal performSpringFling
calculation of the targetIndex
(your index you want to scroll to in your ViewPager) being the same as your current index thus resulting in no movement.
If you disable overscroll, you'll get your intended behavior but a better solution would be to implement your own FlingBehavior