Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of rotation and pinch gesture on android #2983

Merged
merged 7 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ class PinchGestureHandler : GestureHandler<PinchGestureHandler>() {
if (sourceEvent.actionMasked == MotionEvent.ACTION_POINTER_UP) {
activePointers -= 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think activePointers is being used anymore, can you remove it?

}
if (state == STATE_ACTIVE && activePointers < 2) {
end()
} else if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
fail()

if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
if (state == STATE_ACTIVE) {
end()
} else {
fail()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,21 @@ class RotationGestureDetector(private val gestureListener: OnRotationGestureList
updateCurrent(event)
gestureListener?.onRotation(this)
}
MotionEvent.ACTION_POINTER_UP -> if (isInProgress) {
MotionEvent.ACTION_POINTER_UP -> {
val pointerId = event.getPointerId(event.actionIndex)
if (pointerId == pointerIds[0] || pointerId == pointerIds[1]) {
// One of the key pointer has been lifted up, we have to end the gesture
finish()

// All key pointers are up
if (!isInProgress && pointerId == pointerIds[0]) {
gestureListener?.onRotationEnd(this)
}

// One of the key pointers is up
if (isInProgress && pointerIds.contains(pointerId)) {
if (pointerId == pointerIds[0]) {
pointerIds[0] = pointerIds[1]
}
pointerIds[1] = MotionEvent.INVALID_POINTER_ID
isInProgress = false
}
j-piasecki marked this conversation as resolved.
Show resolved Hide resolved
}
MotionEvent.ACTION_UP -> finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RotationGestureHandler : GestureHandler<RotationGestureHandler>() {
anchorY = point.y
}
if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
if (state == STATE_ACTIVE) {
if (state == STATE_ACTIVE && sourceEvent.pointerCount == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? I think it's the same as with pinch - pointerCount may never be equal to 0.

end()
} else {
fail()
Expand Down
Loading