PagerSnapDistance

Interface

Common
interface PagerSnapDistance

PagerSnapDistance defines the way the Pager will treat the distance between the current page and the page where it will settle.

Functions

fun calculateTargetPage(
        startPage: Int,
        suggestedTargetPage: Int,
        velocity: Float,
        pageSize: Int,
        pageSpacing: Int,
    ): Int

Provides a chance to change where the Pager fling will settle.

Parameters

startPageThe current page right before the fling starts.
suggestedTargetPageThe proposed target page where this fling will stop. This target will be the page that will be correctly positioned (snapped) after naturally decaying with velocity using a DecayAnimationSpec.
velocityThe initial fling velocity.
pageSizeThe page size for this Pager in pixels.
pageSpacingThe spacing used between pages in pixels.

Returns

An updated target page where to settle. Note that this value needs to be between 0 and the total count of pages in this pager. If an invalid value is passed, the pager will coerce within the valid values.