Package-level declarations

Types

Link copied to clipboard
@RequiresOptIn(message = "This API is experimental and is likely to change or to be removed in the future.")
annotation class ExperimentalZoomableApi
Link copied to clipboard

Specifies mouse wheel zoom behaviour.

Link copied to clipboard

ScrollGesturePropagation defines when Modifier.zoomable propagates scroll gestures to the parent composable element.

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

A state object that manage scale and offset.

Functions

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

Creates a ZoomState that is remembered across compositions.

Link copied to clipboard
fun Modifier.snapBackZoomable(zoomState: ZoomState, zoomEnabled: Boolean = true, onTap: (position: Offset) -> Unit? = null, onDoubleTap: suspend (position: Offset) -> Unit? = null, onLongPress: (position: Offset) -> Unit? = null): Modifier

A modifier function that allows content to be zoomable and automatically return to its original size when the finger is released.

Link copied to clipboard
fun SnapBackZoomableBox(modifier: Modifier = Modifier, zoomState: ZoomState = rememberZoomState(), scrim: Color = Color.Black.copy(alpha = 0.6f), onTap: (position: Offset) -> Unit? = null, content: @Composable () -> Unit)

A container that makes its content zoomable with snap-back behavior while allowing the zoomed content to escape the clipping bounds of its parent.

Link copied to clipboard
fun SnapBackZoomableOverlayHost(modifier: Modifier = Modifier, content: @Composable () -> Unit)

Provides a shared overlay for every SnapBackZoomableBox nested inside content. Place this at (or near) the root of your compose tree so the overlay can extend across the entire window, including system bar areas.

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

Toggle the scale between targetScale and 1.0f.

Link copied to clipboard
fun Modifier.zoomable(zoomState: ZoomState, zoomEnabled: Boolean = true, enableOneFingerZoom: Boolean = true, scrollGesturePropagation: ScrollGesturePropagation = ScrollGesturePropagation.ContentEdge, onTap: (position: Offset) -> Unit? = null, onDoubleTap: suspend (position: Offset) -> Unit? = { position -> if (zoomEnabled) zoomState.toggleScale(2.5f, position) }, onLongPress: (position: Offset) -> Unit? = null, mouseWheelZoom: MouseWheelZoom = MouseWheelZoom.EnabledWithCtrlKey): Modifier

A modifier function that allows content to be zoomable.

Link copied to clipboard
fun Modifier.zoomableWithScroll(zoomState: ZoomState, zoomEnabled: Boolean = true, enableOneFingerZoom: Boolean = true, scrollGesturePropagation: ScrollGesturePropagation = ScrollGesturePropagation.ContentEdge, onTap: (position: Offset) -> Unit? = null, onDoubleTap: suspend (position: Offset) -> Unit? = { position -> if (zoomEnabled) zoomState.toggleScale(2.5f, position) }, onLongPress: (position: Offset) -> Unit? = null, mouseWheelZoom: MouseWheelZoom = MouseWheelZoom.EnabledWithCtrlKey): Modifier

A modifier function that allows scrollable content to be zoomable.