---
title: "DraggableAnchors"
description: "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."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
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

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val size: Int
```


The number of anchors



## Functions

```kotlin
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 |



```kotlin
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 |



```kotlin
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 |


#### Returns

| | |
| --- | --- |
|  | The closest anchor or null if the anchors are empty. |



```kotlin
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 |



```kotlin
fun minPosition(): Float
```


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


```kotlin
fun maxPosition(): Float
```


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


```kotlin
fun anchorAt(index: Int): T?
```


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


```kotlin
fun positionAt(index: Int): Float
```


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



