Skip to content

Commit fb2a038

Browse files
update DynamicCropState
Don't call onMove if touch region is outside of overlay rectangle
1 parent 11c5495 commit fb2a038

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

cropper/src/main/java/com/smarttoolfactory/cropper/state/CropStateImpl.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ abstract class CropState internal constructor(
271271
* should fit inside draw image rectangle to have valid bounds when calculation is completed.
272272
*
273273
* @param rectOverlay rectangle of overlay that is used for cropping
274-
* @param rectImage rectangle of image that is being drawn
274+
* @param rectDrawArea rectangle of image that is being drawn
275275
*/
276-
private fun calculateValidImageDrawRect(rectOverlay: Rect, rectImage: Rect): Rect {
276+
private fun calculateValidImageDrawRect(rectOverlay: Rect, rectDrawArea: Rect): Rect {
277277

278-
var width = rectImage.width
279-
var height = rectImage.height
278+
var width = rectDrawArea.width
279+
var height = rectDrawArea.height
280280

281281
if (width < rectOverlay.width) {
282282
width = rectOverlay.width
@@ -286,7 +286,7 @@ abstract class CropState internal constructor(
286286
height = rectOverlay.height
287287
}
288288

289-
var rectImageArea = Rect(offset = rectImage.topLeft, size = Size(width, height))
289+
var rectImageArea = Rect(offset = rectDrawArea.topLeft, size = Size(width, height))
290290

291291
if (rectImageArea.left > rectOverlay.left) {
292292
rectImageArea = rectImageArea.translate(rectOverlay.left - rectImageArea.left, 0f)

cropper/src/main/java/com/smarttoolfactory/cropper/state/DynamicCropState.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class DynamicCropState internal constructor(
118118

119119
// If overlay is touched and pointer size is one update
120120
// or pointer size is bigger than one but touched any handles update
121-
if (changes.size == 1 && !gestureInvoked) {
121+
if (touchRegion != TouchRegion.None && changes.size == 1 && !gestureInvoked) {
122122

123123
val change = changes.first()
124124

@@ -134,7 +134,6 @@ class DynamicCropState internal constructor(
134134
)
135135

136136
snapOverlayRectTo(newRect)
137-
// moveOverlayToBounds(change = change, newRect = newRect)
138137
}
139138
}
140139

0 commit comments

Comments
 (0)