Skip to content

Commit 6aa0557

Browse files
add motion callbacks to CropModifier
Callbacks for touch down, move and up events for freehand crop
1 parent 8a1c391 commit 6aa0557

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cropper/src/main/java/com/smarttoolfactory/cropper/CropModifier.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ fun Modifier.crop(
4444
vararg keys: Any?,
4545
cropState: CropState,
4646
zoomOnDoubleTap: (ZoomLevel) -> Float = cropState.DefaultOnDoubleTap,
47+
onDown: ((CropData) -> Unit)? = null,
48+
onMove: ((CropData) -> Unit)? = null,
49+
onUp: ((CropData) -> Unit)? = null,
4750
onGestureStart: ((CropData) -> Unit)? = null,
4851
onGesture: ((CropData) -> Unit)? = null,
49-
onGestureEnd: ((CropData) -> Unit)? = null,
52+
onGestureEnd: ((CropData) -> Unit)? = null
5053
) = composed(
5154

5255
factory = {
@@ -113,19 +116,19 @@ fun Modifier.crop(
113116
onDown = {
114117
coroutineScope.launch {
115118
cropState.onDown(it)
116-
onGestureStart?.invoke(cropState.cropData)
119+
onDown?.invoke(cropState.cropData)
117120
}
118121
},
119122
onMove = {
120123
coroutineScope.launch {
121124
cropState.onMove(it)
122-
onGesture?.invoke(cropState.cropData)
125+
onMove?.invoke(cropState.cropData)
123126
}
124127
},
125128
onUp = {
126129
coroutineScope.launch {
127130
cropState.onUp(it)
128-
onGestureEnd?.invoke(cropState.cropData)
131+
onUp?.invoke(cropState.cropData)
129132
}
130133
}
131134
)

0 commit comments

Comments
 (0)