Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

androidx.compose.foundation.gestures

Interfaces

PressGestureScope

Receiver scope for detectTapGestures's onPress lambda.

ScrollScope

Scope used for suspending scroll blocks

Classes

ScrollableController

Controller to control the scrollable modifier with.

ZoomableController

Controller to control zoomable modifier with.

Exceptions

GestureCancellationException

A gesture was canceled and cannot continue, likely because another gesture has taken over the pointer input stream.

Top-level functions summary

ScrollableController
rememberScrollableController(interactionState: InteractionState? = null, consumeScrollDelta: (Float) -> Float)

Create and remember ScrollableController for scrollable with default FlingConfig and AnimationClockObservable

ZoomableController
rememberZoomableController(onZoomDelta: (Float) -> Unit)

Create and remember ZoomableController with default AnimationClockObservable.

Extension functions summary

For HandlePointerInputScope
suspend PointerInputChange?

Reads pointer input events until a drag is detected or all pointers are up.

suspend PointerInputChange
HandlePointerInputScope.awaitFirstDown(requireUnconsumed: Boolean = true)

Reads events until the first down is received.

suspend PointerInputChange?

Reads pointer input events until a horizontal drag is detected or all pointers are up.

suspend PointerInputChange?
HandlePointerInputScope.awaitHorizontalTouchSlopOrCancellation(pointerId: PointerId, onTouchSlopReached: (change: PointerInputChange, overSlop: Float) -> Unit)

Waits for horizontal drag motion to pass touch slop, using pointerId as the pointer to examine.

suspend PointerInputChange?
HandlePointerInputScope.awaitTouchSlopOrCancellation(pointerId: PointerId, onTouchSlopReached: (change: PointerInputChange, overSlop: Offset) -> Unit)

Waits for drag motion to pass touch slop, using pointerId as the pointer to examine.

suspend PointerInputChange?

Reads pointer input events until a vertical drag is detected or all pointers are up.

suspend PointerInputChange?
HandlePointerInputScope.awaitVerticalTouchSlopOrCancellation(pointerId: PointerId, onTouchSlopReached: (change: PointerInputChange, overSlop: Float) -> Unit)

Waits for vertical drag motion to pass touch slop, using pointerId as the pointer to examine.

suspend Boolean
HandlePointerInputScope.drag(pointerId: PointerId, onDrag: (PointerInputChange) -> Unit)

Reads position change events for pointerId and calls onDrag for every change in position.

suspend Boolean
HandlePointerInputScope.horizontalDrag(pointerId: PointerId, onDrag: (PointerInputChange) -> Unit)

Reads horizontal position change events for pointerId and calls onDrag for every change in position.

suspend Boolean
HandlePointerInputScope.verticalDrag(pointerId: PointerId, onDrag: (PointerInputChange) -> Unit)

Reads vertical position change events for pointerId and calls onDrag for every change in position.

suspend PointerInputChange?

Reads events until all pointers are up or the gesture was canceled.

For PointerEvent
Offset
PointerEvent.calculateCentroid(useCurrent: Boolean = true)

Returns the centroid of all pointers that are down and were previously down.

Float

Returns the average distance from the centroid for all pointers that are currently and were previously down.

Offset

Returns the change in the centroid location between the previous and the current pointers that are down.

Float

Returns the rotation, in degrees, of the pointers between the PointerInputChange.previous and PointerInputChange.current states.

Float

Uses the change of the centroid size between the PointerInputChange.previous and PointerInputChange.current to determine how much zoom was intended.

For PointerInputScope
suspend Unit
PointerInputScope.detectDragGestures(onDragEnd: () -> Unit = { }, onDragCancel: () -> Unit = { }, onDrag: (change: PointerInputChange, dragAmount: Offset) -> Unit)

Gesture detector that waits for pointer down and touch slop in any direction and then calls onDrag for each drag event.

suspend Unit
PointerInputScope.detectHorizontalDragGestures(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.

suspend Unit
PointerInputScope.detectMultitouchGestures(panZoomLock: Boolean = false, onRotate: (rotation: Float) -> Unit = NoRotateZoom, onZoom: (zoom: Float) -> Unit = NoRotateZoom, onPan: (pan: Offset) -> Unit = NoPan)

A gesture detector for rotationg, panning, and zoom.

suspend Unit
PointerInputScope.detectTapGestures(onDoubleTap: () -> Unit = null, onLongPress: () -> Unit = null, onPress: suspend PressGestureScope.(Offset) -> Unit = NoPressGesture, onTap: () -> Unit)

Detects tap, double-tap, and long press gestures and calls onTap, onDoubleTap, and onLongPress, respectively, when detected.

suspend Unit
PointerInputScope.detectVerticalDragGestures(onDragEnd: () -> Unit = { }, onDragCancel: () -> Unit = { }, onVerticalDrag: (change: PointerInputChange, dragAmount: Float) -> Unit)

Gesture detector that waits for pointer down and touch slop in the vertical direction and then calls onVerticalDrag for each vertical drag event.

suspend Unit

Repeatedly calls block to handle gestures.

For Modifier
Modifier
Modifier.draggable(orientation: Orientation, enabled: Boolean = true, reverseDirection: Boolean = false, interactionState: InteractionState? = null, startDragImmediately: Boolean = false, canDrag: (Direction) -> Boolean = { enabled }, onDragStarted: (startedPosition: Offset) -> Unit = {}, onDragStopped: (velocity: Float) -> Unit = {}, onDrag: Density.(Float) -> Unit)

Configure touch dragging for the UI element in a single Orientation.

Modifier
Modifier.scrollable(orientation: Orientation, controller: ScrollableController, enabled: Boolean = true, reverseDirection: Boolean = false, canScroll: (Direction) -> Boolean = { enabled }, onScrollStarted: (startedPosition: Offset) -> Unit = {}, onScrollStopped: (velocity: Float) -> Unit = {})

Configure touch scrolling and flinging for the UI element in a single Orientation.

Modifier
Modifier.zoomable(controller: ZoomableController, enabled: Boolean = true, onZoomStarted: () -> Unit = null, onZoomStopped: () -> Unit = null)

Enable zooming of the modified UI element.

Modifier
Modifier.zoomable(enabled: Boolean = true, onZoomStarted: () -> Unit = null,