Closed SubhrajyotiSen closed 1 year ago
Is ZoomableState#zoomFraction
what you're looking for?
https://saket.github.io/telephoto/zoomable/recipes/#observing-pan-zoom
Yes, this works perfectly. I was looking at the wrong place in the code.
Hi @saket,
I'm unable to reproduce expected behavior of the snippet in https://saket.github.io/telephoto/zoomable/recipes/#observing-pan-zoom
val zoomableState = rememberZoomableState()
ZoomableAsyncImage(
model = capturedItem.uri,
contentDescription = null,
modifier = Modifier
.zoomable(
state = zoomableState,
)
.fillMaxSize()
)
LaunchedEffect(zoomableState.contentTransformation) {
println("Pan = ${zoomableState.contentTransformation.offset}")
println("Zoom = ${zoomableState.contentTransformation.scale}")
println("Zoom fraction = ${zoomableState.zoomFraction}")
}
(This code is within a pager's composable callback for each page)
The zoom works as expected but I'm really unable to listen to the zoom updates unfortunately. I'm doing this to get my gallery in focus mode when the user has zoomed in and out of that mode when the user has completely zoomed out.
By any chance did any compose update cause the behavior of LaunchedEffect to change or am I doing something wrong Any help would be highly appreciated
PS: Thanks a lot for building out this great library with your valuable time and efforts!
Using Modifier.zoomable
on a parent container/composable and using AsyncImage
seemed to resolve the issue instead of applying Modifier.zoomable
on the main ZoomableAsyncImage
I am currently using https://github.com/Baseflow/PhotoView in our app and we have a requirement to log analytics event if an user interacted with the image (zoom/pan etc.)
For this, we use the provided
setOnScaleChangeListener
method which gets a callback from https://github.com/Baseflow/PhotoView/blob/565505d5cb84f5977771b5d2ccb7726338e77224/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java#LL151C18-L151C18It would be great if telephoto could support something similar.