Optional zoom on double click
This commit is contained in:
parent
90eb7b4575
commit
dab9784089
@ -8,6 +8,7 @@ public data class ViewConfig<T : Any>(
|
|||||||
val dragHandle: DragHandle<T>? = null,
|
val dragHandle: DragHandle<T>? = null,
|
||||||
val onViewChange: ViewPoint<T>.() -> Unit = {},
|
val onViewChange: ViewPoint<T>.() -> Unit = {},
|
||||||
val onSelect: (Rectangle<T>) -> Unit = {},
|
val onSelect: (Rectangle<T>) -> Unit = {},
|
||||||
val zoomOnSelect: Boolean = true,
|
|
||||||
val onCanvasSizeChange: (DpSize) -> Unit = {},
|
val onCanvasSizeChange: (DpSize) -> Unit = {},
|
||||||
|
val zoomOnSelect: Boolean = true,
|
||||||
|
val zoomOnDoubleClick: Boolean = true
|
||||||
)
|
)
|
@ -19,7 +19,6 @@ import kotlin.math.min
|
|||||||
public fun <T : Any> Modifier.mapControls(
|
public fun <T : Any> Modifier.mapControls(
|
||||||
state: CoordinateViewScope<T>,
|
state: CoordinateViewScope<T>,
|
||||||
features: FeatureGroup<T>,
|
features: FeatureGroup<T>,
|
||||||
zoomOnDoubleClick: Boolean = true,
|
|
||||||
): Modifier = with(state) {
|
): Modifier = with(state) {
|
||||||
|
|
||||||
// //selecting all tapabales ahead of time
|
// //selecting all tapabales ahead of time
|
||||||
@ -48,8 +47,8 @@ public fun <T : Any> Modifier.mapControls(
|
|||||||
}
|
}
|
||||||
}.pointerInput(Unit) {
|
}.pointerInput(Unit) {
|
||||||
detectClicks(
|
detectClicks(
|
||||||
onDoubleClick = { event ->
|
onDoubleClick = if (state.config.zoomOnDoubleClick) {
|
||||||
if (zoomOnDoubleClick) {
|
{ event ->
|
||||||
val invariant = event.position.toCoordinates(this)
|
val invariant = event.position.toCoordinates(this)
|
||||||
viewPoint = with(space) {
|
viewPoint = with(space) {
|
||||||
viewPoint.zoomBy(
|
viewPoint.zoomBy(
|
||||||
@ -58,7 +57,7 @@ public fun <T : Any> Modifier.mapControls(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
} else null,
|
||||||
onClick = { event ->
|
onClick = { event ->
|
||||||
val coordinates = event.position.toCoordinates(this)
|
val coordinates = event.position.toCoordinates(this)
|
||||||
val point = space.ViewPoint(coordinates, zoom)
|
val point = space.ViewPoint(coordinates, zoom)
|
||||||
|
Loading…
Reference in New Issue
Block a user