pagingFlingBehavior

fun pagingFlingBehavior(layoutInfo: PagingLayoutInfo, decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(), snapAnimationSpec: AnimationSpec<Float> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = Int.VisibilityThreshold.toFloat() ), @FloatRange(from = 0.0, to = 1.0) snapPositionalThreshold: Float = 0.5f): TargetedFlingBehavior

A snapFlingBehavior that will snap pages to the start of the layout. One can use the given parameters to control how the snapping animation will happen.

Return

An instance of FlingBehavior that will perform Snapping to the next page by default.

Parameters

layoutInfo

The PagingLayoutInfo that describes the pager layout.

snapAnimationSpec

The animation spec used to finally snap to the position. This animation will be often used in 2 cases: 1) There was enough space to an approach animation, the Pager will use snapAnimationSpec in the last step of the animation to settle the page into position. 2) There was not enough space to run the approach animation.

snapPositionalThreshold

If the fling has a low velocity (e.g. slow scroll), this fling behavior will use this snap threshold in order to determine if the pager should snap back or move forward. Use a number between 0 and 1 as a fraction of the page size that needs to be scrolled before the Pager considers it should move to the next page. For instance, if snapPositionalThreshold = 0.35, it means if this pager is scrolled with a slow velocity and the Pager scrolls more than 35% of the page size, then will jump to the next page, if not it scrolls back. Note that any fling that has high enough velocity will always move to the next page in the direction of the fling.

See also

for more information on what which parameter controls in the overall snapping animation.