# DraggableState

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/gestures/Draggable.kt+class:androidx.compose.foundation.gestures.DraggableState) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface DraggableState
  ```
Known direct subclasses [DragToResizeState](https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/DragToResizeState), [SliderState](https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/DragToResizeState` | A state object that can be used to control the resizing behavior of a pane. |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState` | Class that holds information about `https://developer.android.com/reference/kotlin/androidx/compose/material3/Slider.composable#Slider(kotlin.Float,kotlin.Function1,androidx.compose.ui.Modifier,kotlin.Boolean,kotlin.ranges.ClosedFloatingPointRange,kotlin.Int,kotlin.Function0,androidx.compose.material3.SliderColors,androidx.compose.foundation.interaction.MutableInteractionSource)`'s active range. |

*** ** * ** ***

State of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/draggable.modifier#(androidx.compose.ui.Modifier).draggable(androidx.compose.foundation.gestures.DraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean,kotlin.coroutines.SuspendFunction2,kotlin.coroutines.SuspendFunction2,kotlin.Boolean)`. Allows for a granular control of how deltas are consumed by the user as well as to write custom drag methods using `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` suspend function.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#dispatchRawDelta(kotlin.Float)(delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Dispatch drag delta in pixels avoiding all drag related priority mechanisms. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)(dragPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DragScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Call this function to take control of drag logic. | Cmn |

## Public functions

### dispatchRawDelta

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
fun dispatchRawDelta(delta: Float): Unit
```

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

**NOTE:** unlike `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)`, dispatching any delta with this method will bypass scrolling of any priority. This method will also ignore `reverseDirection` and other parameters set in `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/draggable.modifier#(androidx.compose.ui.Modifier).draggable(androidx.compose.foundation.gestures.DraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean,kotlin.coroutines.SuspendFunction2,kotlin.coroutines.SuspendFunction2,kotlin.Boolean)`.

This method is used internally for low level operations, allowing implementers of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState` influence the consumption as suits them, e.g. introduce nested scrolling. Manually dispatching delta via this method will likely result in a bad user experience, you must prefer `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` method over this one.

| Parameters |
|---|---|
| `delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | amount of scroll dispatched in the nested drag process |

### drag

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
suspend fun drag(
    dragPriority: MutatePriority = MutatePriority.Default,
    block: suspend DragScope.() -> Unit
): Unit
```

Call this function to take control of drag logic.

All actions that change the logical drag position must be performed within a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.

If `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` is called from elsewhere with the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` higher or equal to ongoing drag, ongoing drag will be canceled.

| Parameters |
|---|---|
| `dragPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority = MutatePriority.Default` | of the drag operation |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DragScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | to perform drag in |