<h2 id="detecthorizontaldraggestures-ondragstart-ondragend-ondragcancel-onhorizontaldrag">detectHorizontalDragGestures</h2>

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

```kotlin
suspend fun PointerInputScope.detectHorizontalDragGestures(
    onDragStart: (Offset) -> Unit = {},
    onDragEnd: () -> Unit = {},
    onDragCancel: () -> Unit = {},
    onHorizontalDrag: (change: PointerInputChange, dragAmount: Float) -> Unit,
)
```

Gesture detector that waits for pointer down and touch slop in the horizontal direction and then
calls `onHorizontalDrag` for each horizontal drag event. It follows the touch slop detection of
[awaitHorizontalTouchSlopOrCancellation](/jetpack-compose/androidx.compose.foundation/foundation/functions/awaitHorizontalTouchSlopOrCancellation), but will consume the position change automatically once
the touch slop has been crossed.

`onDragStart` called when the touch slop has been passed and includes an [Offset](/jetpack-compose/androidx.compose.ui/ui-geometry/functions/Offset) representing
the last known pointer position relative to the containing element. The [Offset](/jetpack-compose/androidx.compose.ui/ui-geometry/functions/Offset) can be outside
the actual bounds of the element itself meaning the numbers can be negative or larger than the
element bounds if the touch target is smaller than the
[ViewConfiguration.minimumTouchTargetSize](/jetpack-compose/androidx.compose.ui/ui/interfaces/ViewConfiguration).

`onDragEnd` is called after all pointers are up and `onDragCancel` is called if another gesture
has consumed pointer input, canceling this gesture.

This gesture detector will coordinate with [detectVerticalDragGestures](/jetpack-compose/androidx.compose.foundation/foundation/functions/detectVerticalDragGestures) and
[awaitVerticalTouchSlopOrCancellation](/jetpack-compose/androidx.compose.foundation/foundation/functions/awaitVerticalTouchSlopOrCancellation) to ensure only vertical or horizontal dragging is locked,
but not both.

Example Usage: