SnapBackZoomableBox

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.

Pinch zoom and pan gestures are supported; when the pointers are released the content animates back to its original size and position.

While a gesture is in progress (including the snap-back animation), content is rendered as an overlay over a scrim background. If this box is nested inside a SnapBackZoomableOverlayHost, the overlay lives in that host (and may extend across system bar areas); otherwise it falls back to a platform Popup.

Example:

SnapBackZoomableBox(modifier = Modifier.fillMaxSize()) {
AsyncImage(model = url, modifier = Modifier.fillMaxSize())
}

Parameters

modifier

The modifier applied to the anchor area (the original touch target).

zoomState

A ZoomState object. Defaults to rememberZoomState.

scrim

Color painted behind the zoomed content. Its alpha is multiplied by the zoom progress so the scrim fades in as the user zooms past 1x and fades out during the snap-back animation. Pass Color.Transparent to disable.

onTap

Called when a single tap is detected.

content

The zoomable content.