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

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

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

Loading…
Cancel
Save