Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay between double tap zoom is too long #73

Closed
David8aO opened this issue Jun 10, 2023 · 5 comments
Closed

Delay between double tap zoom is too long #73

David8aO opened this issue Jun 10, 2023 · 5 comments

Comments

@David8aO
Copy link

I'm using coil's AsyncImages inside an HorizontalPager but since the time between the double tap zoom is kinda long, swiping relatively fast leads to unwanted zooms.
Im pretty sure this can be fixed by making the time between the 2 taps shorter.

Example: https://gyazo.com/2bc85ed503b4d5ab4772b610accbcd0d
In this example i wasn't trying to zoom in the images, but just to swipe between them.
Could you please fix it?

@usuiat
Copy link
Owner

usuiat commented Jun 10, 2023

@David8aO
Thank you for your inquiry.
I also tried the combination of Coil and HorizontalPager but could not get the symptoms you mentioned.

The gesture detection algorithm does not recognize the swipe as a double tap no matter how fast you swipe.
This is because if your finger moves on the screen, it is determined to be a swipe, not a tap or double tap.
Therefore, I think something else is going on.

@David8aO
Copy link
Author

David8aO commented Jun 10, 2023

Oh yhea, i forgot to mention i'm applying the zoomable modifier to the whole pager, instead of to each AsyncImage, because that way the zoom stops working randomly after a few swipes, please try this code out yourself.

val linkList = listOf(
"https://images2.imgbox.com/0d/f8/0ITo0HPx_o.jpg",
"https://images2.imgbox.com/02/03/jMPfhWE0_o.jpg",
"https://images2.imgbox.com/18/fc/9CIXu8kk_o.jpg",
"https://images2.imgbox.com/78/de/3tXEFY1N_o.jpg"
)
val pagerState = rememberPagerState {
linkList.size
}
HorizontalPager(
state = pagerState,
) { pageNumber ->
val zoomState = rememberZoomState()
AsyncImage(
modifier = Modifier
.fillMaxSize()
.zoomable(zoomState),
model = linkList[pageNumber],
contentDescription = "",
onSuccess = { state ->
zoomState.setContentSize(state.painter.intrinsicSize)
}
)
}
in the previous code, Zoom glitches and stops working at the 4th pic, but applying the modifier to the whole pager fixes it (code below).
I'm using compose foundation 1.5.0 horizontal pager by the way.

val linkList = listOf(
"https://images2.imgbox.com/0d/f8/0ITo0HPx_o.jpg",
"https://images2.imgbox.com/02/03/jMPfhWE0_o.jpg",
"https://images2.imgbox.com/18/fc/9CIXu8kk_o.jpg",
"https://images2.imgbox.com/78/de/3tXEFY1N_o.jpg"
)
val pagerState = rememberPagerState {
linkList.size
}
val zoomState = rememberZoomState()
HorizontalPager(
state = pagerState,
modifier = Modifier.zoomable(zoomState),
) { pageNumber ->
AsyncImage(
modifier = Modifier
.fillMaxSize(),
model = linkList[pageNumber],
contentDescription = "",
onSuccess = { state ->
zoomState.setContentSize(state.painter.intrinsicSize)
}
)
}
Applying the zoomable modifier to the entire pager (previous code) will fix the zooming behaviour glitching, but instead will trigger unwanted zooms using the double tap feature (what i originally opened the issue for)

I hope you could help me out with this. thanks in advance

@IacobIonut01
Copy link

I've had this issue earlier with the beta version of compose (foundation). It's actually a bug in the library itself, I recommend reverting back to 1.4.3 (stable)

@usuiat
Copy link
Owner

usuiat commented Jun 11, 2023

@David8aO
I understand your situation.
Zoomable is intended to be applied to AsyncImage as in your former example code. But as @IacobIonut01 said, current version of Zoomable does not work with compose v1.5.0-beta. Could you use compose v1.4.3 for now.
I will close this issue, but I will continue to investigate it in #74
Thanks for your report.

@IacobIonut01
Thank you for your comment.
I opened another issue about compose v1.5. If you have further information, I would be grateful if you could tell me.

@usuiat usuiat closed this as completed Jun 11, 2023
@IacobIonut01
Copy link

@David8aO I understand your situation. Zoomable is intended to be applied to AsyncImage as in your former example code. But as @IacobIonut01 said, current version of Zoomable does not work with compose v1.5.0-beta. Could you use compose v1.4.3 for now. I will close this issue, but I will continue to investigate it in #74 Thanks for your report.

@IacobIonut01 Thank you for your comment. I opened another issue about compose v1.5. If you have further information, I would be grateful if you could tell me.

No problem, as I've stated in my opened issue, it's clearly an internal problem inside the compose 1.5.0 beta, as the gestures suddenly stop working - the pager is consuming all of them, after 2 or 3 swipes, but it starts working again after Configuration changes (orientation, fold state etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants