-
Notifications
You must be signed in to change notification settings - Fork 20
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
Option to Set a Minimum Scale #71
Comments
By default, the minimum scale is calculated based on the image size, container size, and contentScale, but you can fully customize minScale, mediumScale, and maxScale through ScalesCalculator. Please refer to the documentation and the existing implementation of ScalesCalculator |
I tried to create a custom implementation of data class PredefinedScalesCalculator(
val minScale: Float,
val mediumScale: Float,
val maxScale: Float
): ScalesCalculator {
override fun calculate(
containerSize: IntSizeCompat,
contentSize: IntSizeCompat,
contentOriginSize: IntSizeCompat,
contentScale: ContentScaleCompat,
minScale: Float,
initialScale: Float
): ScalesCalculator.Result {
return ScalesCalculator.Result(
minScale = this.minScale,
mediumScale = this.mediumScale,
maxScale = this.maxScale
)
}
} However, I found that only the |
I did have |
Yes, the minScale returned by ScalesCalculator is not used. This is because minScale should usually always be determined by contentScale and keep it consistent with the initial zoom factor. Otherwise, when you double-click to cycle zoom, you will never be able to return to the initial zoom factor, which violates user intuition. Can you explain in detail why you need to modify minScale? I'll consider whether there are other ways to achieve your goal. zoomimage/zoomimage-core/src/commonMain/kotlin/com/github/panpf/zoomimage/zoom/zooms.kt Line 286 in edce97f
|
Since I'm trying to show a metro map. The initial zoom is set to a size that makes the map readable. Zooming all the way out does not make any sense as the map and the stations would be so tiny especially if your screen is in portrait mode. |
Don't use Fit for your contentScale, use None, and set rubberBandScale to false |
Thanks for the suggestion, in kinda works. Although it is still not the best as it would be you can't zoom out more than the initial scale. Although the map is not readable at the smallest possible scale, allowing the user to zoom out just a little bit from the initial scale is still desirable. Sorry for nitpicking on the library haha, make no mistake it is already great! |
I understand that you only want to zoom in and not zoom out, so I let you use None, which will not do any scaling on the image. When rubberBandScale is false, you can only zoom in. If I understand it wrongly, please explain the requirements in more detail or give a demonstration video. |
It would be great if an option is available to set the minimum scale the image. (So that you can restrict users from zooming out all the way)
The text was updated successfully, but these errors were encountered: