androidx.compose.foundation.gestures.snapping

SnapPosition

Interface · from org.jetbrains.compose.foundation:foundation:1.12.2

No hand-written docs yet.

Describes the snapping positioning (i.e. final positioning after snapping animation finishes) of a given snap item in its containing layout.

interface SnapPosition

Kinds of SnapPosition

Anywhere a SnapPosition is expected, you can pass any of these.

How to get one

Ready-made values and functions that return it

Or create one of the kinds listed above.

Used by

Parameters that take a SnapPosition.

Functions

position

fun position(
    layoutSize: Int,
    itemSize: Int,
    beforeContentPadding: Int,
    afterContentPadding: Int,
    itemIndex: Int,
    itemCount: Int,
): Int

Calculates the snap position where items will be aligned to in a snapping container. For instance, if SnapPosition.Center is used, once the snapping finishes the center of one of the items in the snapping container will be aligned exactly to the center of the snapping container, that is because the value returned by position was calculated as such a way that when one applies it to the item's current offset it will generate that final positioning.

Nested types

Library docs

Describes the snapping positioning (i.e. final positioning after snapping animation finishes) of a given snap item in its containing layout.