DraggableAnchors



Structure that represents the anchors of a AnchoredDraggableState.

See the DraggableAnchors factory method to construct drag anchors using a default implementation.

Summary

Public functions

T?
closestAnchor(position: Float)

Find the closest anchor to the position.

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

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

Cmn
Unit
forEach(block: (anchor, position: Float) -> Unit)

Iterate over all the anchors and corresponding positions.

Cmn
Boolean
hasAnchorFor(value: T)

Whether there is an anchor position associated with the value

Cmn
Float

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

Cmn
Float

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

Cmn
Float
positionOf(value: T)

Get the anchor position for an associated value

Cmn

Public properties

Int

The amount of anchors

Cmn

Public functions

closestAnchor

fun closestAnchor(position: Float): T?

Find the closest anchor 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 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

forEach

fun forEach(block: (anchor, position: Float) -> Unit): Unit

Iterate over all the anchors and corresponding positions.

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

The action to invoke with the anchor and position

hasAnchorFor

fun hasAnchorFor(value: T): Boolean

Whether there is an anchor position associated with the value

Parameters
value: 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

maxAnchor

fun maxAnchor(): Float

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

minAnchor

fun minAnchor(): Float

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

positionOf

fun positionOf(value: T): Float

Get the anchor position for an associated value

Parameters
value: 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 amount of anchors