Compose-Image icon indicating copy to clipboard operation
Compose-Image copied to clipboard

Gesture Behavior Override in EnhancedZoom Modifier

Open Ten-Wang opened this issue 2 years ago • 0 comments

Hello,

I'm using the library code as shown below:

AsyncImage(
        model = imageRequest,
        imageLoader = imageLoader,
        modifier = modifier.enhancedZoom(
            key = "zoomable",
            clip = true,
            enhancedZoomState = rememberEnhancedZoomState(
                minZoom = .5f,
                maxZoom = 10f,
                imageSize = IntSize(imageWidth, imageHeight),
                limitPan = false,
                moveToBounds = true,
            ),
            zoomOnDoubleTap = { zoomLevel: ZoomLevel ->
                println("zoomOnDoubleTap")
                when (zoomLevel) {
                    ZoomLevel.Mid -> 3f
                    ZoomLevel.Min -> 1f
                    ZoomLevel.Max -> 5f
                }
            },
            enabled = { zoom, pan, rotation ->
                zoom > 1f
            }
        ).pointerInput("zoomable") {
            detectTapGestures(
                onTap = { println("onTap") },
                onDoubleTap = { println("onDoubleTap") },
                onLongPress = { println("onLongPress") })
        },
    )

However, I've noticed that using detectTapGestures seems to override the gesture behavior defined in zoomOnDoubleTap. Interestingly, when I use another library (https://github.com/usuiat/Zoomable), I don't encounter this issue. Upon inspecting their source code, I found that they override the behavior of PointerInputScope.detectTransformGestures (https://github.com/usuiat/Zoomable/blob/main/zoomable/src/main/java/net/engawapg/lib/zoomable/Zoomable.kt). Is there a way to ensure that gesture behavior is not overridden in this library?

Thank you.

Ten-Wang avatar Oct 13 '23 02:10 Ten-Wang