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

Support programmatically changing pan/zoom #4

Closed
DSteve595 opened this issue May 14, 2023 · 2 comments
Closed

Support programmatically changing pan/zoom #4

DSteve595 opened this issue May 14, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@DSteve595
Copy link
Collaborator

It would be nice to be able to programmatically manipulate the transformation of the image, initially and over time.
Use cases:

  • A comic reader wants to start at the top, probably one of the corners
  • A map wants to start viewing a specific location
@DSteve595 DSteve595 added the enhancement New feature or request label May 14, 2023
@saket saket self-assigned this Mar 28, 2024
This was referenced Mar 28, 2024
@nateridderman
Copy link

nateridderman commented Jun 7, 2024

A map wants to start viewing a specific location

💯 this is my use case. This library is awesome, and this issue is the one thing it's missing before I can adopt it in my app.

@saket
Copy link
Owner

saket commented Jul 2, 2024

The next release will introduce new APIs for controlling an image's pan and zoom. @nateridderman will this solve your use case?

/**
* Zooms in or out around [centroid] by a ratio of [zoomFactor] relative to the current size,
* and suspends until it's finished.
*
* @param zoomFactor Ratio by which to zoom relative to the current size. For example, a [zoomFactor]
* of `3f` will triple the *current* zoom level.
*
* @param centroid Focal point for this zoom within the content's size. Defaults to the center
* of the content.
*
* @param animationSpec The animation spec to use or [SnapSpec] for no animation.
*/
suspend fun zoomBy(
zoomFactor: Float,
centroid: Offset = Offset.Unspecified,
animationSpec: AnimationSpec<Float> = DefaultZoomAnimationSpec,
)
/**
* Zooms in or out around [centroid] to achieve a final zoom level specified by [zoomFactor],
* and suspends until it's finished.
*
* @param zoomFactor Target zoom level for the content. For example, a [zoomFactor] of `3f` will
* set the content's zoom level to three times its *original* size.
*
* @param centroid Focal point for this zoom within the content's size. Defaults to the center
* of the content.
*
* @param animationSpec The animation spec to use or [SnapSpec] for no animation.
*/
suspend fun zoomTo(
zoomFactor: Float,
centroid: Offset = Offset.Unspecified,
animationSpec: AnimationSpec<Float> = DefaultZoomAnimationSpec,
)
/**
* Animate pan by [offset] Offset in pixels and suspend until it's finished.
*
* @param animationSpec The animation spec to use or [SnapSpec] for no animation.
*/
suspend fun panBy(
offset: Offset,
animationSpec: AnimationSpec<Offset> = DefaultPanAnimationSpec,
)

@saket saket closed this as completed Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants