Browse Source

Fixed Draggable & Scalable for desktop.

pull/4/head
spvessel 4 years ago
parent
commit
743a300bc0
  1. 7
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt
  2. 3
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Scalable.kt

7
examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt

@ -24,7 +24,7 @@ import androidx.compose.foundation.InteractionState
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.gesture.DragObserver
import androidx.compose.ui.gesture.dragGestureFilter
import androidx.compose.ui.gesture.rawDragGestureFilter
import androidx.compose.runtime.mutableStateOf
import example.imageviewer.core.EventLocker
import example.imageviewer.style.Transparent
@ -37,8 +37,9 @@ fun Draggable(
) {
Surface(
color = Transparent,
modifier = modifier.dragGestureFilter(
dragObserver = onDrag
modifier = modifier.rawDragGestureFilter(
dragObserver = onDrag,
canStartDragging = { true }
)
) {
children()

3
examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Scalable.kt

@ -37,7 +37,8 @@ fun Scalable(
Surface(
color = Transparent,
modifier = modifier.rawScaleGestureFilter(
scaleObserver = onScale
scaleObserver = onScale,
canStartScaling = { true }
).doubleTapGestureFilter(onDoubleTap = { onScale.resetFactor() }),
) {
children()

Loading…
Cancel
Save