usuiat / Zoomable

Jetpack Compose library that enables contents zooming with pinch gesture.
https://usuiat.github.io/Zoomable/
Apache License 2.0
342 stars 16 forks source link

Zoom on double tap #152

Closed T8RIN closed 4 months ago

T8RIN commented 6 months ago
onDoubleTap = { position ->
    when (zoomState.scale) {
        in 1f..<5f -> {
            zoomState.changeScale(5f, position)
        }
        in 5f..<10f -> {
            zoomState.changeScale(10f, position)
        }
        else -> {
            zoomState.changeScale(1f, position)
        }
    }
}

if there will be parameter level, then it will be easeir to manage, like

onDoubleTap = { position, level ->
    when (level) {
        ZoomLevel.Min -> {
            zoomState.changeScale(1f, position)
        }
        ZoomLevel.Mid-> {
            zoomState.changeScale(5f, position)
        }
        ZoomLevel.Max-> {
            zoomState.changeScale(10f, position)
        }
    }
}
T8RIN commented 6 months ago

image

Like this, but zoomState need to expand its internal maxZoom parameter and also include minZoom one

usuiat commented 6 months ago

@T8RIN I do not think it is a good idea to fix the number of steps of level to 3. Different apps have different requirements for double-tap behavior. Therefore, Zoomable provides a double-tap handler without enforcing a specific number of steps.

In fact, many apps, such as Google Photo and X, change scale in two steps with a double tap. This is why Zoomable's default double-tap handler is implemented in two steps.

T8RIN commented 6 months ago

Hm, with this implementation add two leveled way easier, maybe just add additional modifier?

T8RIN commented 6 months ago

Okay, i will remove it, and create additional zoom handler param in object defaults

T8RIN commented 6 months ago

Done @usuiat