🌈 Create new beautiful Compose Gradients with our new wesite ->
Interface

SnapPosition

Describes the snapping positioning (i.e.

Source set: Common
public interface SnapPosition

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

Functions

position

Source set: Common
public 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.

The reference point is with respect to the start of the layout (including the content padding)

Parameters

layoutSize The main axis layout size within which an item can be positioned.
itemSize The main axis size for the item being positioned within this snapping layout.
beforeContentPadding The content padding in pixels applied before this Layout's content.
afterContentPadding The content padding in pixels applied after this Layout's content.
itemIndex The index of the item being positioned.
itemCount The total amount of items in the snapping container.

Return

The offset of the snap position where items will be aligned to in a snapping container.

Members

Center

Source set: Common
public object Center : SnapPosition

Aligns the center of the item with the center of the containing layout.

Functions

position

Source set: Common
override fun position(
            layoutSize: Int,
            itemSize: Int,
            beforeContentPadding: Int,
            afterContentPadding: Int,
            itemIndex: Int,
            itemCount: Int,
        ): Int

toString

Source set: Common
override fun toString(): String

Start

Source set: Common
public object Start : SnapPosition

Aligns the start of the item with the start of the containing layout.

Functions

position

Source set: Common
override fun position(
            layoutSize: Int,
            itemSize: Int,
            beforeContentPadding: Int,
            afterContentPadding: Int,
            itemIndex: Int,
            itemCount: Int,
        ): Int

toString

Source set: Common
override fun toString(): String

End

Source set: Common
public object End : SnapPosition

Aligns the end of the item with the end of the containing layout.

Functions

position

Source set: Common
override fun position(
            layoutSize: Int,
            itemSize: Int,
            beforeContentPadding: Int,
            afterContentPadding: Int,
            itemIndex: Int,
            itemCount: Int,
        ): Int

toString

Source set: Common
override fun toString(): String