saket / telephoto

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

Modifier.zoomable() applied separately from ZoomableAsyncImage doesn't force the image to stay in bounds when zoomed-in #21

Closed K1rakishou closed 1 year ago

K1rakishou commented 1 year ago

I tried to apply zoomable to a video player and found out that there is this bug.

MRE:

val zoomSpec = remember { ZoomSpec(maxZoomFactor = 3f) }
val zoomableState = rememberZoomableState(zoomSpec = zoomSpec)

// AsyncImage from coil
AsyncImage(
  modifier = modifier
    .zoomable(state = zoomableState),
  model = ImageRequest.Builder(LocalContext.current)
    .data(imageUrl)
    .crossfade(300)
    .build(),
  contentDescription = "",
)

device-2023-05-27-155256.webm

It works when using ZoomableAsyncImage, though. Only doesn't work when using Modifier.zoomable() separately. Can't tell for sure what might be the cause.

saket commented 1 year ago

Are you missing https://saket.github.io/telephoto/zoomable/#edge-detection?

K1rakishou commented 1 year ago

Ok I see. Kinda missed that part.

saket commented 1 year ago

Yea it is easy to miss. I'll move that section above to the top so that it is slightly more noticeable.