Optional zoom on double click

This commit is contained in:
Alexander Nozik 2023-02-13 17:01:16 +03:00
parent 90eb7b4575
commit dab9784089
2 changed files with 5 additions and 5 deletions

View File

@ -8,6 +8,7 @@ public data class ViewConfig<T : Any>(
val dragHandle: DragHandle<T>? = null,
val onViewChange: ViewPoint<T>.() -> Unit = {},
val onSelect: (Rectangle<T>) -> Unit = {},
val zoomOnSelect: Boolean = true,
val onCanvasSizeChange: (DpSize) -> Unit = {},
val zoomOnSelect: Boolean = true,
val zoomOnDoubleClick: Boolean = true
)

View File

@ -19,7 +19,6 @@ import kotlin.math.min
public fun <T : Any> Modifier.mapControls(
state: CoordinateViewScope<T>,
features: FeatureGroup<T>,
zoomOnDoubleClick: Boolean = true,
): Modifier = with(state) {
// //selecting all tapabales ahead of time
@ -48,8 +47,8 @@ public fun <T : Any> Modifier.mapControls(
}
}.pointerInput(Unit) {
detectClicks(
onDoubleClick = { event ->
if (zoomOnDoubleClick) {
onDoubleClick = if (state.config.zoomOnDoubleClick) {
{ event ->
val invariant = event.position.toCoordinates(this)
viewPoint = with(space) {
viewPoint.zoomBy(
@ -58,7 +57,7 @@ public fun <T : Any> Modifier.mapControls(
)
}
}
},
} else null,
onClick = { event ->
val coordinates = event.position.toCoordinates(this)
val point = space.ViewPoint(coordinates, zoom)