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

DraggableAnchors

Structure that represents the anchors of a AnchoredDraggableState.

Source set: Common
public interface DraggableAnchors<T>

Structure that represents the anchors of a AnchoredDraggableState.

See the DraggableAnchors factory method to construct drag anchors using a default implementation. This structure does not make any guarantees about ordering of the anchors.

Properties

size

Source set: Common
public val size: Int

The number of anchors

Functions

positionOf

Source set: Common
public fun positionOf(anchor: T): Float

Get the anchor position for an associated anchor

Parameters

anchor The value to look up

Return

The position of the anchor, or Float.NaN if the anchor does not exist

hasPositionFor

Source set: Common
public fun hasPositionFor(anchor: T): Boolean

Whether there is an anchor position associated with the anchor

Parameters

anchor The value to look up

Return

true if there is an anchor for this value, false if there is no anchor for this value

closestAnchor

Source set: Common
public fun closestAnchor(position: Float): T?

Find the closest anchor value to the position. If there are multiple anchors at the same offset, it is up to the implementation which will be returned. When using the DraggableAnchors factory function, this will be the last anchor of the candidates at this offset.

Parameters

position The position to start searching from

Return

The closest anchor or null if the anchors are empty.

closestAnchor

Source set: Common
public fun closestAnchor(position: Float, searchUpwards: Boolean): T?

Find the closest anchor value to the position, in the specified direction.

Parameters

position The position to start searching from
searchUpwards Whether to search upwards from the current position or downwards

Return

The closest anchor or null if the anchors are empty

minPosition

Source set: Common
public fun minPosition(): Float

The smallest anchor position, or Float.NaN if the anchors are empty.

maxPosition

Source set: Common
public fun maxPosition(): Float

The biggest anchor position, or Float.NaN if the anchors are empty.

anchorAt

Source set: Common
public fun anchorAt(index: Int): T?

Get the anchor key at the specified index, or null if the index is out of bounds.

positionAt

Source set: Common
public fun positionAt(index: Int): Float

Get the anchor position at the specified index, or Float.NaN if the index is out of bounds.