# OnSwipe

Artifact: [androidx.constraintlayout:constraintlayout-compose](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/compose/TransitionScope.kt+class:androidx.constraintlayout.compose.OnSwipe) Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

<br />

```
@ExperimentalMotionApi
class OnSwipe
```

<br />

*** ** * ** ***

Defines the OnSwipe behavior for a `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Transition`.

When swiping, the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayout.composable#MotionLayout(androidx.constraintlayout.compose.ConstraintSet,androidx.constraintlayout.compose.ConstraintSet,kotlin.Float,androidx.compose.ui.Modifier,androidx.constraintlayout.compose.Transition,androidx.constraintlayout.compose.DebugFlags,kotlin.Int,androidx.constraintlayout.compose.InvalidationStrategy,kotlin.Function1)` is updated to a progress value so that the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` is laid out in a position corresponding to the drag.

In other words, `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe` allows you to drive `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/MotionLayout.composable#MotionLayout(androidx.constraintlayout.compose.ConstraintSet,androidx.constraintlayout.compose.ConstraintSet,kotlin.Float,androidx.compose.ui.Modifier,androidx.constraintlayout.compose.Transition,androidx.constraintlayout.compose.DebugFlags,kotlin.Int,androidx.constraintlayout.compose.InvalidationStrategy,kotlin.Function1)` by dragging a specific `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#OnSwipe(androidx.constraintlayout.compose.ConstrainedLayoutReference,androidx.constraintlayout.compose.SwipeSide,androidx.constraintlayout.compose.SwipeDirection,kotlin.Float,kotlin.Float,androidx.constraintlayout.compose.ConstrainedLayoutReference,androidx.constraintlayout.compose.ConstrainedLayoutReference,androidx.constraintlayout.compose.SwipeTouchUp,androidx.constraintlayout.compose.SwipeMode)( anchor: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference, side: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeSide, direction: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeDirection, dragScale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, dragThreshold: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, dragAround: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference?, limitBoundsTo: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference?, onTouchUp: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeTouchUp, mode: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeMode )` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#anchor()` The `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` to track through touch input. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeDirection` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#direction()` Expected swipe direction to start the animation through touch handling. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference?` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#dragAround()` When not-null, causes the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#anchor()` to be dragged around the center of the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` in a circular motion. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#dragScale()` Scaling factor applied on the dragged distance, meaning that the larger the scaling value, the shorter distance is required to animate the entire Transition. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#dragThreshold()` Distance in pixels required to consider the drag as initiated. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference?` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#limitBoundsTo()` When not-null, the touch handling won't be initiated unless it's within the bounds of the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference`. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeMode` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#mode()` Describes how MotionLayout animates during `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#onTouchUp()`. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeTouchUp` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#onTouchUp()` Defines what behavior MotionLayout should have when the drag event is interrupted by TouchUp. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeSide` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#side()` Side of the bounds to track, this is to account for when the tracked widget changes size during the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Transition`. |

## Public constructors

### OnSwipe

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
OnSwipe(
    anchor: ConstrainedLayoutReference,
    side: SwipeSide,
    direction: SwipeDirection,
    dragScale: Float = 1.0f,
    dragThreshold: Float = 10.0f,
    dragAround: ConstrainedLayoutReference? = null,
    limitBoundsTo: ConstrainedLayoutReference? = null,
    onTouchUp: SwipeTouchUp = SwipeTouchUp.AutoComplete,
    mode: SwipeMode = SwipeMode.velocity()
)
```

| Parameters |
|---|---|
| `anchor: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` | The `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` to track through touch input. |
| `side: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeSide` | Side of the bounds to track, this is to account for when the tracked widget changes size during the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Transition`. |
| `direction: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeDirection` | Expected swipe direction to start the animation through touch handling. Typically, this is the direction the widget takes to the end `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`. |
| `dragScale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 1.0f` | Scaling factor applied on the dragged distance, meaning that the larger the scaling value, the shorter distance is required to animate the entire Transition. 1f by default. |
| `dragThreshold: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 10.0f` | Distance in pixels required to consider the drag as initiated. 10 by default. |
| `dragAround: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference? = null` | When not-null, causes the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#anchor()` to be dragged around the center of the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` in a circular motion. |
| `limitBoundsTo: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference? = null` | When not-null, the touch handling won't be initiated unless it's within the bounds of the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference`. Useful to deal with touch handling conflicts. |
| `onTouchUp: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeTouchUp = SwipeTouchUp.AutoComplete` | Defines what behavior MotionLayout should have when the drag event is interrupted by TouchUp. `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeTouchUp#AutoComplete()` by default. |
| `mode: https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeMode = SwipeMode.velocity()` | Describes how MotionLayout animates during `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#onTouchUp()`. `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeMode#velocity(kotlin.Float,kotlin.Float)` by default. |

## Public properties

### anchor

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val anchor: ConstrainedLayoutReference
```

The `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` to track through touch input.

### direction

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val direction: SwipeDirection
```

Expected swipe direction to start the animation through touch handling. Typically, this is the direction the widget takes to the end `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstraintSet`.

### dragAround

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val dragAround: ConstrainedLayoutReference?
```

When not-null, causes the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#anchor()` to be dragged around the center of the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference` in a circular motion.

### dragScale

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val dragScale: Float
```

Scaling factor applied on the dragged distance, meaning that the larger the scaling value, the shorter distance is required to animate the entire Transition. 1f by default.

### dragThreshold

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val dragThreshold: Float
```

Distance in pixels required to consider the drag as initiated. 10 by default.

### limitBoundsTo

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val limitBoundsTo: ConstrainedLayoutReference?
```

When not-null, the touch handling won't be initiated unless it's within the bounds of the given `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/ConstrainedLayoutReference`. Useful to deal with touch handling conflicts.

### mode

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val mode: SwipeMode
```

Describes how MotionLayout animates during `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/OnSwipe#onTouchUp()`. `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeMode#velocity(kotlin.Float,kotlin.Float)` by default.

### onTouchUp

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val onTouchUp: SwipeTouchUp
```

Defines what behavior MotionLayout should have when the drag event is interrupted by TouchUp. `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/SwipeTouchUp#AutoComplete()` by default.

### side

Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

```
val side: SwipeSide
```

Side of the bounds to track, this is to account for when the tracked widget changes size during the `https://developer.android.com/reference/kotlin/androidx/constraintlayout/compose/Transition`.