usuiat / Zoomable

Jetpack Compose library that enables contents zooming with pinch gesture.
https://usuiat.github.io/Zoomable/
Apache License 2.0
325 stars 15 forks source link

Single Tap isn't strict #177

Closed Perfomer closed 4 months ago

Perfomer commented 4 months ago

Preconditions:

Problem: I faced the issue when onTap callback invokes by swipe gesture, not a tap. It reproduces when you swipe slightly so Pager even doesn't change the page.

You can see it on the video:

https://github.com/usuiat/Zoomable/assets/16479387/56621acd-473e-425c-8cc0-efac99c41d3a

Code:

HorizontalPager(
    state = pagerState,
    modifier = Modifier.fillMaxSize()
) { page ->
    val zoomState = rememberZoomState()
    AsyncImage(
        model = state.picturesUri[page],
        contentDescription = null,
        onSuccess = { pictureState -> zoomState.setContentSize(pictureState.painter.intrinsicSize) },
        contentScale = ContentScale.Fit,
        modifier = Modifier
            .fillMaxSize()
            .zoomable(
                zoomState = zoomState,
                enableOneFingerZoom = false,
                onTap = {
                    Log.d("MyTag", "onTap() triggered")
                    onPagerClick() // <<< Hide UI in onPagerClick()
                },
            )
        )
}

Ask: Could you please make the onTap callback more strict, so it doesn't trigger with slight swipes?

usuiat commented 4 months ago

@Perfomer Thank you for creating an issue.

Could you try v1.6.1-beta01?

I found that sometimes HorizontalPager scrolling and Zoomable onTap evnet can occur at the same time. The cause was that Zoomable did not cancel gesture handling when the parent composable consumed PointerEvents.

Now I fixed to cancel gesture handling.

Perfomer commented 4 months ago

Now it works great! Thank you!

usuiat commented 4 months ago

Good! I will close this issue and will release v1.6.1.