How do I set min and max size (instead of using `f...
# compose
r
How do I set min and max size (instead of using
fillMaxSize()
) of box having pinch to zoom ability? code is in thread.
Copy code
@Composable
fun PinchToZoomDemo() {
    var scale by remember { mutableStateOf(1f) }
    val state = rememberTransformableState { zoomChange, _, _ ->
        scale *= zoomChange
    }
    Box(modifier = Modifier
        .graphicsLayer {
            scaleX = scale
            scaleY = scale
        }
        .transformable(state = state)
        .background(Color.Red)
        .fillMaxSize()
    )
}
a
You mean min and max zoom level? In that case you can just use something like
scale = (scale * zoomChange).coerceIn(1f, 2f)
.
r
Great. thanks.