androidx.compose.foundation.gestures

transformable

Function · from org.jetbrains.compose.foundation:foundation:1.12.2

No hand-written docs yet.

Enable transformation gestures of the modified UI element.

Form 1

fun Modifier.transformable(
    state: TransformableState,
    lockRotationOnZoomPan: Boolean = false,
    enabled: Boolean = true,
)

state: TransformableStateRequired

TransformableState of the transformable. Defines how transformation events will be interpreted by the user land logic, contains useful information about on-going events and provides animation capabilities.

lockRotationOnZoomPan: BooleanOptional

Default: false

If true, rotation is allowed only if touch slop is detected for rotation before pan or zoom motions. If not, pan and zoom gestures will be detected, but rotation gestures will not be. If false, once touch slop is reached, all three gestures are detected.

enabled: BooleanOptional

Default: true

whether zooming by gestures is enabled or not

With canPan

fun Modifier.transformable(
    state: TransformableState,
    canPan: (Offset) -> Boolean,
    lockRotationOnZoomPan: Boolean = false,
    enabled: Boolean = true,
)

canPan: (Offset) -> BooleanRequired

whether the pan gesture can be performed or not given the pan offset

Same as above: state, lockRotationOnZoomPan, enabled.

Library docs

Enable transformation gestures of the modified UI element.

Users should update their state themselves using default TransformableState and its onTransformation callback or by implementing TransformableState interface manually and reflect their own state in UI when using this component.