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: android - Pinch gesture handler when one finger is lifted #1800

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -13,6 +13,8 @@ class PinchGestureHandler : GestureHandler<PinchGestureHandler>() {
private set
val focalPointX: Float
get() = scaleGestureDetector?.focusX ?: Float.NaN
var activePointers = 0
private set
val focalPointY: Float
get() = scaleGestureDetector?.focusY ?: Float.NaN

Expand Down Expand Up @@ -60,11 +62,11 @@ class PinchGestureHandler : GestureHandler<PinchGestureHandler>() {
begin()
}
scaleGestureDetector?.onTouchEvent(event)
var activePointers = event.pointerCount
activePointers = event.pointerCount
if (event.actionMasked == MotionEvent.ACTION_POINTER_UP) {
activePointers -= 1
}
if (state == STATE_ACTIVE && activePointers < 2) {
if (state == STATE_ACTIVE && event.actionMasked == MotionEvent.ACTION_UP) {
end()
} else if (event.actionMasked == MotionEvent.ACTION_UP) {
fail()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
putDouble("focalX", PixelUtil.toDIPFromPixel(handler.focalPointX).toDouble())
putDouble("focalY", PixelUtil.toDIPFromPixel(handler.focalPointY).toDouble())
putDouble("velocity", handler.velocity)
putDouble("numberOfPointers", handler.activePointers.toDouble())
}
}
}
Expand Down