Google is committed to advancing racial equity for Black communities. See how.

ZoomableController

class ZoomableController
kotlin.Any
   ↳ androidx.compose.foundation.gestures.ZoomableController

Controller to control zoomable modifier with. Provides smooth scaling capabilities.

Summary

Public constructors
<init>(animationClock: AnimationClockObservable, onZoomDelta: (Float) -> Unit)

Controller to control zoomable modifier with.

Public methods
Unit
smoothScaleBy(value: Float, spec: AnimationSpec<Float> = SpringSpec(stiffness = Spring.StiffnessLow), onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = null)

Smooth scale by a ratio of value over the current size.

Unit

Stop any ongoing animation or smooth scaling for this controller

Properties
(Float) -> Unit

callback to be invoked when pinch/smooth zooming occurs.

Public constructors

<init>

ZoomableController(
    animationClock: AnimationClockObservable,
    onZoomDelta: (Float) -> Unit)

Controller to control zoomable modifier with. Provides smooth scaling capabilities.

Parameters
animationClock: AnimationClockObservable clock observable to run animation on. Consider querying AnimationClockAmbient to get current composition value
onZoomDelta: (Float) -> Unit callback to be invoked when pinch/smooth zooming occurs. The callback receives the delta as the ratio of the new size compared to the old. Callers should update their state and UI in this callback.

Public methods

smoothScaleBy

fun smoothScaleBy(
    value: Float,
    spec: AnimationSpec<Float> = SpringSpec(stiffness = Spring.StiffnessLow),
    onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = null
): Unit

Smooth scale by a ratio of value over the current size.

Parameters
value: Float ratio over the current size by which to scale
spec: AnimationSpec<Float> = SpringSpec(stiffness = Spring.StiffnessLow) AnimationSpec to be used for smoothScale animation

stopAnimation

fun stopAnimation(): Unit

Stop any ongoing animation or smooth scaling for this controller

Call this to stop receiving scrollable deltas in onZoomDelta

Properties

onZoomDelta

val onZoomDelta: (Float) -> Unit

callback to be invoked when pinch/smooth zooming occurs. The callback receives the delta as the ratio of the new size compared to the old. Callers should update their state and UI in this callback.