DraggableAnchors


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.

Summary

Public functions

T?
anchorAt(index: Int)

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

Cmn
T?
closestAnchor(position: Float)

Find the closest anchor value to the position.

Cmn
T?
closestAnchor(position: Float, searchUpwards: Boolean)

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

Cmn
Boolean
hasPositionFor(anchor: T)

Whether there is an anchor position associated with the anchor

Cmn
Float

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

Cmn
Float

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

Cmn
Float
positionAt(index: Int)

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

Cmn
Float
positionOf(anchor: T)

Get the anchor position for an associated anchor

Cmn

Public properties

Int

The number of anchors

Cmn

Extension functions

inline Unit
<T : Any?> DraggableAnchors<T>.forEach(block: (key, position: Float) -> Unit)

Iterate over all the anchors.

Cmn

Public functions

anchorAt

fun anchorAt(index: Int): T?

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

closestAnchor

fun closestAnchor(position: Float): T?

Find the closest anchor value to the position.

Parameters
position: Float

The position to start searching from

Returns
T?

The closest anchor or null if the anchors are empty

closestAnchor

fun closestAnchor(position: Float, searchUpwards: Boolean): T?

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

Parameters
position: Float

The position to start searching from

searchUpwards: Boolean

Whether to search upwards from the current position or downwards

Returns
T?

The closest anchor or null if the anchors are empty

hasPositionFor

fun hasPositionFor(anchor: T): Boolean

Whether there is an anchor position associated with the anchor

Parameters
anchor: T

The value to look up

Returns
Boolean

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

maxPosition

fun maxPosition(): Float

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

minPosition

fun minPosition(): Float

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

positionAt

fun positionAt(index: Int): Float

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

positionOf

fun positionOf(anchor: T): Float

Get the anchor position for an associated anchor

Parameters
anchor: T

The value to look up

Returns
Float

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

Public properties

size

val sizeInt

The number of anchors

Extension functions

inline fun <T : Any?> DraggableAnchors<T>.forEach(block: (key, position: Float) -> Unit): Unit

Iterate over all the anchors.

Parameters
block: (key, position: Float) -> Unit

The action to invoke with the key and position