ZoomState

class ZoomState(@FloatRange(from = 1.0) maxScale: Float = 5.0f, contentSize: Size = Size.Zero, velocityDecay: DecayAnimationSpec<Float> = exponentialDecay())

A state object that manage scale and offset.

Parameters

maxScale

The maximum scale of the content.

contentSize

Size of content (i.e. image size.) If Zero, the composable layout size will be used as content size.

velocityDecay

The decay animation spec for fling behaviour.

Constructors

Link copied to clipboard
constructor(@FloatRange(from = 1.0) maxScale: Float = 5.0f, contentSize: Size = Size.Zero, velocityDecay: DecayAnimationSpec<Float> = exponentialDecay())

Properties

Link copied to clipboard

The horizontal offset of the content.

Link copied to clipboard

The vertical offset of the content.

Link copied to clipboard

The scale of the content.

Functions

Link copied to clipboard
suspend fun centerByContentCoordinate(offset: Offset, scale: Float = 3.0f, animationSpec: AnimationSpec<Float> = tween(700))

Animates the centering of content by modifying the offset and scale based on content coordinates.

Link copied to clipboard
suspend fun centerByLayoutCoordinate(offset: Offset, scale: Float = 3.0f, animationSpec: AnimationSpec<Float> = tween(700))

Animates the centering of content by modifying the offset and scale based on layout coordinates.

Link copied to clipboard
suspend fun changeScale(targetScale: Float, position: Offset, animationSpec: AnimationSpec<Float> = spring()): Job

Change the scale with animation.

Link copied to clipboard
suspend fun reset(): Job

Reset the scale and the offsets.

Link copied to clipboard
fun setContentSize(size: Size)

Set the content size.

Link copied to clipboard
fun setLayoutSize(size: Size)

Set composable layout size.

Link copied to clipboard
suspend fun ZoomState.toggleScale(targetScale: Float, position: Offset, animationSpec: AnimationSpec<Float> = spring())

Toggle the scale between targetScale and 1.0f.