Closed Mett-Barr closed 6 months ago
I need to restrict zoom and scroll functionality to either the X or Y axis
Additionally, I'm looking for a way to access and update the current ZoomableState during zoom events via a callback
Can you share some more context for both of these usecases?
For your question posted here, wanna try applying the transformations yourself? This way you can filter the scale/offset values reported by telephoto's gesture listener along your desired axis.
val state = rememberZoomableState(
zoomSpec = ZoomSpec(10f),
autoApplyTransformations = false,
)
SineWave(
Modifier
.weight(1f)
.fillMaxWidth()
.zoomable(state, clipToBounds = false)
.applyTransformation(state.contentTransformation)
)
fun Modifier.applyTransformation(transformation: ZoomableContentTransformation): Modifier {
return graphicsLayer {
scaleX = transformation.scale.scaleX
//scaleY = transformation.scale.scaleY
translationX = transformation.offset.x
//translationY = transformation.offset.y
transformOrigin = transformation.transformOrigin
}
}
Thank you very much for your response. The solution you provided works perfectly. I probably should have thought of this approach myself after realizing that the Current ZoomableState Update was available. Nevertheless, I am extremely grateful for your assistance. It has been incredibly helpful. Thank you again for providing such an excellent library.
Hello, first off, thanks for your work on this library. I'm currently integrating it into a project where I need to restrict zoom and scroll functionality to either the X or Y axis. Additionally, I'm looking for a way to access and update the current ZoomableState during zoom events via a callback. Is there an existing method in the library to handle these requirements, or are these features something that could be considered for future development?