DraggableAnchors
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
val size: Int
The number of anchors
Functions
fun positionOf(anchor: T): Float
Get the anchor position for an associated anchor
Parameters
anchor | The value to look up |
Returns
The position of the anchor, or Float.NaN if the anchor does not exist |
fun hasPositionFor(anchor: T): Boolean
Whether there is an anchor position associated with the anchor
Parameters
anchor | The value to look up |
Returns
true if there is an anchor for this value, false if there is no anchor for this value |
fun closestAnchor(position: Float): T?
Find the closest anchor value to the position
.
Parameters
position | The position to start searching from |
Returns
The closest anchor or null if the anchors are empty |
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 |
Returns
The closest anchor or null if the anchors are empty |
fun minPosition(): Float
The smallest anchor position, or Float.NEGATIVE_INFINITY
if the anchors are empty.
fun maxPosition(): Float
The biggest anchor position, or Float.POSITIVE_INFINITY
if the anchors are empty.
fun anchorAt(index: Int): T?
Get the anchor key at the specified index, or null if the index is out of bounds.
fun positionAt(index: Int): Float
Get the anchor position at the specified index, or Float.NaN
if the index is out of bounds.