# DragToResizeState

Artifact: [androidx.compose.material3.adaptive:adaptive-layout](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/adaptive/layout/DragToResizeState.kt+class:androidx.compose.material3.adaptive.layout.DragToResizeState) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive#1.3.0) Common/All
- Cmn

  ```
  @ExperimentalMaterial3AdaptiveApi
  abstract class DragToResizeState : DraggableState
  ```

*** ** * ** ***

A state object that can be used to control the resizing behavior of a pane.

This class provides a way to track the current size of a resizable pane and to handle drag interactions that modify the size. It supports both horizontal and vertical resizing.

This state object is primarily designed for internal use within pane scaffolds.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.adaptive.layout.AnimatedPane
import androidx.compose.material3.adaptive.layout.PaneExpansionAnchor
import androidx.compose.material3.adaptive.layout.PaneExpansionState
import androidx.compose.material3.adaptive.layout.SupportingPaneScaffold
import androidx.compose.material3.adaptive.layout.rememberPaneExpansionState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

val coroutineScope = rememberCoroutineScope()
val scaffoldNavigator = levitateAsBottomSheetSample<NavItemData>()
val extraItems = listOf("Extra content")
val selectedItem = NavItemData(index = 0, showExtra = true)

SupportingPaneScaffold(
    directive = scaffoldNavigator.scaffoldDirective,
    scaffoldState = scaffoldNavigator.scaffoldState,
    mainPane = {
        AnimatedPane {
            MainPaneContent(
                scaffoldNavigator = scaffoldNavigator,
                hasExtraPane = true,
                coroutineScope = coroutineScope,
            )
        }
    },
    supportingPane = {
        AnimatedPane(modifier = Modifier.preferredWidth(200.dp)) { SupportingPaneContent() }
    },
    extraPane = {
        AnimatedPane(
            modifier =
                Modifier.preferredWidth(1f)
                    .preferredHeight(0.5f)
                    .background(MaterialTheme.colorScheme.surface),
            dragToResizeHandle = { BottomSheetDefaults.DragHandle() },
        ) {
            ExtraPaneContent(
                extraItems = extraItems,
                selectedItem = selectedItem,
                scaffoldNavigator = scaffoldNavigator,
                coroutineScope = coroutineScope,
            )
        }
    },
    paneExpansionState =
        rememberPaneExpansionState(
            keyProvider = scaffoldNavigator.scaffoldValue,
            anchors = PaneExpansionAnchors,
        ),
    paneExpansionDragHandle = { state -> PaneExpansionDragHandleSample(state) },
)
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/rememberDragToResizeState.composable#rememberDragToResizeState(androidx.compose.material3.adaptive.layout.DockedEdge,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/AdaptStrategy.Levitate` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneAdaptedValue.Levitated` |   |

## Summary

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/DragToResizeState#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 |
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/DragToResizeState#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.3.0](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive#1.3.0)

```
open 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.3.0](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive#1.3.0)

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