saket / telephoto

Building blocks for designing media experiences in Compose UI
https://saket.github.io/telephoto/
Apache License 2.0
869 stars 28 forks source link

Better zoom gestures #65

Closed IacobIonut01 closed 4 months ago

IacobIonut01 commented 4 months ago

I've tried your libray for subsampling in my Gallery app and I've noticed that the zoomable gesture handler is not as good as the previous solution I've used (https://github.com/usuiat/Zoomable) specially when used with lots of gesture (swipe up vertically, horizontal pager scroll etc)

Would be great if you can look into that library or allow the use of it because it would make the solution much better for Gallery/Media Viewer usescases

For Horizontal Pager even with the scroll disabled, it still conflicts with the other gesutres (swipe up)

LaunchedEffect(zoomableState.zoomFraction) {
    scrollEnabled.value = (zoomableState.zoomFraction ?: 0f) == 0.0f
}

Thanks!

saket commented 4 months ago

I've noticed that the zoomable gesture handler is not as good as the previous solution I've used (https://github.com/usuiat/Zoomable) specially when used with lots of gesture (swipe up vertically, horizontal pager scroll etc)

Can you share a video of the issues you're seeing? It's difficult to visualize otherwise.

For Horizontal Pager even with the scroll disabled, it still conflicts with the other gesutres (swipe up)

Same question. I'm not sure what's conflicting and a video will help.

IacobIonut01 commented 4 months ago

https://github.com/saket/telephoto/assets/19311643/1f58b7a7-efab-470b-98b6-d4aa6e9e0964

IacobIonut01 commented 4 months ago
ZoomableImage(
    modifier = modifier.fillMaxSize()
        .combinedClickable(
                  interactionSource = remember { MutableInteractionSource() },
                  indication = null,
                  onDoubleClick = {},
                  onClick = onItemClick
        ),
    state = state,
    image = ZoomableImageSource.coil3(
          model = ImageRequest.Builder(LocalPlatformContext.current)
                      .data(media.uri)
                      .placeholderMemoryCacheKey(media.toString())
                      .build()
    ),
    contentScale = ContentScale.Fit,
    contentDescription = media.label
)
IacobIonut01 commented 4 months ago
image
saket commented 4 months ago

The issue happening at 0:05 in the video looks strange. I wonder if it's happening because the image hasn't fully loaded yet. Are you using placeholder images? If so, can you add a loading indicator to verify if the gestures start working only after the image has fully loaded?

Btw, it'd be best if you can share a reproducer for me to investigate instead of going back and forth with questions. Your app looks very cool, I'd love to support it.

IacobIonut01 commented 4 months ago

Here is the app with the subsampling image applied (I've also made a custom source for coil3 (alpha)

For placeholder I'm using the coil's prebuilt memory cache key to get the lower quality image that was previously loaded in a grid view

https://github.com/IacobIonut01/Gallery/tree/0c3fac0b3246f5d82fb4b77ce54d267f2ac7d701

saket commented 4 months ago

@IacobIonut01 I haven't gotten a chance to check out your project yet, but can you try out 0.8.0-SNAPSHOT? I made a small improvement to consume gestures immediately if multiple fingers/pointers are detected in https://github.com/saket/telephoto/commit/4c9118e1680efafc2c6b7b33319f2e281dfc7532.

IacobIonut01 commented 4 months ago

Sure, but I couldn't find it on maven

saket commented 4 months ago

You'll need to add the snapshot repository to your project for accessing snapshot versions:

maven {
  url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
IacobIonut01 commented 4 months ago

Yeah it's better now

saket commented 4 months ago

Glad to hear! Are there any remaining improvements you need?

IacobIonut01 commented 4 months ago

Glad to hear! Are there any remaining improvements you need?

The only feature that is missing is progressive zoom (double tap 2x, another double tap 5x, another double tap max zoom for example)

saket commented 4 months ago

Cool, tracking that in https://github.com/saket/telephoto/issues/32