# Draggable2DState

# Draggable2DState

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/Draggable2D.kt+class:androidx.compose.foundation.gestures.Draggable2DState)  
Added in[1.6.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.6.0)
Common/AllAndroid/JVM
  - Cmn  

  ```
  interface Draggable2DState
  ```

*** ** * ** ***

State of Draggable2D. Allows for granular control of how deltas are consumed by the user as well as to write custom drag methods using[drag](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1))suspend function.

## Summary

|                                  ### Public functions                                   |
|-----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)           | [dispatchRawDelta](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#dispatchRawDelta(androidx.compose.ui.geometry.Offset))`(delta: `[Offset](https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)`)` Dispatch drag delta in pixels avoiding all drag related priority mechanisms.                                                                                                                                                                                                                                       | Cmn |
| `suspend `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [drag](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1))`(dragPriority: `[MutatePriority](https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority)`, block: suspend `[Drag2DScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Drag2DScope)`.() `->` `[Unit](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.10.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0-rc01)  

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

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

**Note:** unlike[drag](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)), dispatching any delta with this method will bypass dragging of any priority. This method will also ignore`reverseDirection`and other parameters set in draggable2D.

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

|                                              Parameters                                               |
|-------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `delta: `[Offset](https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset) | amount of drag dispatched in the nested drag process |

### drag

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

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

Call this function to take control of drag logic.

All actions that change the logical drag position must be performed within a[drag](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#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[drag](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1))is called from elsewhere with the[dragPriority](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/Draggable2DState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1))higher or equal to ongoing drag, ongoing drag will be canceled.  

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