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

Please provide a way to change zoom and offset programatically #67

Open
MitulVarmora opened this issue Feb 19, 2024 · 7 comments
Open

Comments

@MitulVarmora
Copy link

I am building an app in which I would like to save user's last zoom and offset and restore it when user revisit same image.
As of now lib version 0.8.0: There is no way to change zoom and offset programatically.

Please provide a way to change zoom and offset programatically.
This is important to my app because that way user will continue editing image from where they left.

@saket
Copy link
Owner

saket commented Feb 19, 2024

That's a very interesting usecase!

I would like to save user's last zoom and offset

What value do you plan to save? ZoomableState#zoomFraction or ZoomableState#contentTransformation?

@MitulVarmora
Copy link
Author

What value do you plan to save? ZoomableState#zoomFraction or ZoomableState#contentTransformation?

ZoomableState#contentTransformation because thats what contains offset and scale both.

@Tlaster
Copy link

Tlaster commented May 5, 2024

Another application involves utilizing PredictiveBackHandler to animate zoom scale and offset, such as scaling back to the original size when the user presses the back button with predictive back functionality.

@saket
Copy link
Owner

saket commented May 5, 2024

@Tlaster can you use ZoomableState#resetZoom() for that?

@Tlaster
Copy link

Tlaster commented May 5, 2024

@Tlaster can you use ZoomableState#resetZoom() for that?

ZoomableState#resetZoom() will reset the zoom instantly, with PredictiveBackHandler we can get a progress that indicate how many "back" user has been dragged, so we can use the progress to set the scale and offset programmatically. For more about predictive back: https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture

@saket
Copy link
Owner

saket commented May 9, 2024

@Tlaster interesting. Is there a reason you want to change the scale/offset on every frame during the back gesture? I haven't seen any apps do that.

@Tlaster
Copy link

Tlaster commented May 9, 2024

@Tlaster interesting. Is there a reason you want to change the scale/offset on every frame during the back gesture? I haven't seen any apps do that.

Just a thought, like a gallery app when user scale up a photo then want to reset the scale by back gesture, it would be nice to have an animation during back gesture.

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