mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-19 23:05:21 +00:00
* fix(android): keep composer taps working after pinching an image React Native counted two touches at the start of a pinch but received a native takeover cancellation for just one. Typing could then claim the responder and consume the first toolbar tap. Cancel the active contacts when the gesture handler takes over. * docs(android): describe the chat image fixture for the pinch regression
468 lines
22 KiB
Diff
468 lines
22 KiB
Diff
diff --git a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
|
|
index 8d78aea..b84d19e 100644
|
|
--- a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
|
|
+++ b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
|
|
@@ -2,11 +2,13 @@ package com.swmansion.gesturehandler.core
|
|
|
|
import android.graphics.Matrix
|
|
import android.graphics.PointF
|
|
+import android.util.SparseArray
|
|
import android.view.MotionEvent
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.widget.EditText
|
|
import com.facebook.react.uimanager.RootView
|
|
+import com.facebook.react.views.view.ReactViewGroup
|
|
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
|
|
import com.swmansion.gesturehandler.react.RNGestureHandlerRootView
|
|
import com.swmansion.gesturehandler.react.isHoverAction
|
|
@@ -28,6 +30,10 @@ class GestureHandlerOrchestrator(
|
|
private val awaitingHandlers = arrayListOf<GestureHandler>()
|
|
private val preparedHandlers = arrayListOf<GestureHandler>()
|
|
|
|
+ // Used by `cancelTouchesInInterceptedViews`.
|
|
+ private val viewsToCancel = arrayListOf<View>()
|
|
+ private val pointerDownPoints = SparseArray<PointF>()
|
|
+
|
|
// In `onHandlerStateChange` method we iterate through `awaitingHandlers`, but calling `tryActivate` may modify this list.
|
|
// To avoid `ConcurrentModificationException` we iterate through copy. There is one more problem though - if handler was
|
|
// removed from `awaitingHandlers`, it was still present in copy of original list. This hashset helps us identify which handlers
|
|
@@ -46,6 +52,7 @@ class GestureHandlerOrchestrator(
|
|
fun onTouchEvent(event: MotionEvent): Boolean {
|
|
isHandlingTouch = true
|
|
val action = event.actionMasked
|
|
+ trackPointerDownPoints(event)
|
|
if (action == MotionEvent.ACTION_DOWN ||
|
|
action == MotionEvent.ACTION_POINTER_DOWN ||
|
|
action == MotionEvent.ACTION_HOVER_MOVE
|
|
@@ -579,6 +586,115 @@ class GestureHandlerOrchestrator(
|
|
private fun shouldIgnoreSubtreeIfGestureHandlerRootView(view: View) =
|
|
view is RNGestureHandlerRootView && view != wrapperView && view.isRootViewEnabled()
|
|
|
|
+ private fun trackPointerDownPoints(event: MotionEvent) {
|
|
+ val index = event.actionIndex
|
|
+ when (event.actionMasked) {
|
|
+ MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN ->
|
|
+ pointerDownPoints.put(event.getPointerId(index), PointF(event.getX(index), event.getY(index)))
|
|
+ MotionEvent.ACTION_POINTER_UP ->
|
|
+ pointerDownPoints.remove(event.getPointerId(index))
|
|
+ MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL ->
|
|
+ pointerDownPoints.clear()
|
|
+ }
|
|
+ }
|
|
+
|
|
+ fun cancelTouchesInInterceptedViews(event: MotionEvent) {
|
|
+ viewsToCancel.clear()
|
|
+ for (i in 0 until pointerDownPoints.size()) {
|
|
+ val point = pointerDownPoints.valueAt(i)
|
|
+ tempCoords[0] = point.x
|
|
+ tempCoords[1] = point.y
|
|
+ collectViewsAtPoint(wrapperView, tempCoords, viewsToCancel)
|
|
+ }
|
|
+
|
|
+ if (viewsToCancel.isEmpty()) {
|
|
+ return
|
|
+ }
|
|
+
|
|
+ val activeHandlers = gestureHandlers.filter { it.isActive }
|
|
+ val cancelEvent = MotionEvent.obtain(event).apply { action = MotionEvent.ACTION_CANCEL }
|
|
+
|
|
+ for (view in viewsToCancel) {
|
|
+ if (view === wrapperView || isViewDrivenByActiveNativeGesture(view, activeHandlers)) {
|
|
+ continue
|
|
+ }
|
|
+ view.onTouchEvent(cancelEvent)
|
|
+ }
|
|
+
|
|
+ cancelEvent.recycle()
|
|
+ viewsToCancel.clear()
|
|
+ }
|
|
+
|
|
+ // Whether the view's touch is still owned by a NativeViewGestureHandler that survived arbitration.
|
|
+ // Only those are fed through `onTouchEvent`, so only those break if cancelled. Other handlers are
|
|
+ // orchestrator-driven and unaffected.
|
|
+ private fun isViewDrivenByActiveNativeGesture(view: View, activeHandlers: List<GestureHandler>) =
|
|
+ handlerRegistry.getHandlersForView(view)?.let { handlers ->
|
|
+ synchronized(handlers) {
|
|
+ handlers.any { nativeGestureSurvivesArbitration(it, activeHandlers) }
|
|
+ }
|
|
+ } ?: false
|
|
+
|
|
+ // A native handler survives arbitration if it is active, or it does not conflict with any active handler.
|
|
+ private fun nativeGestureSurvivesArbitration(handler: GestureHandler, activeHandlers: List<GestureHandler>) =
|
|
+ handler is NativeViewGestureHandler &&
|
|
+ (handler.isActive || activeHandlers.none { shouldHandlerBeCancelledBy(handler, it) })
|
|
+
|
|
+ // Keep cancellation traversal in the same drawing order as Android touch dispatch.
|
|
+ private fun getChildInDrawingOrderAtIndex(parent: ViewGroup, index: Int): View =
|
|
+ if (parent is ReactViewGroup) {
|
|
+ parent.getChildAt(parent.getZIndexMappedChildIndex(index))
|
|
+ } else {
|
|
+ parent.getChildAt(index)
|
|
+ }
|
|
+
|
|
+ // Collects the view path under the point (topmost child first, like touch dispatch), leaf to root.
|
|
+ private fun collectViewsAtPoint(view: View, coords: FloatArray, out: MutableList<View>): Boolean {
|
|
+ val pointerEvents = viewConfigHelper.getPointerEventsConfigForView(view)
|
|
+ if (pointerEvents == PointerEventsConfig.NONE) {
|
|
+ return false
|
|
+ }
|
|
+
|
|
+ var found = false
|
|
+ if (view is ViewGroup && pointerEvents != PointerEventsConfig.BOX_ONLY) {
|
|
+ for (i in view.childCount - 1 downTo 0) {
|
|
+ val child = getChildInDrawingOrderAtIndex(view, i)
|
|
+ if (!canReceiveEvents(child)) {
|
|
+ continue
|
|
+ }
|
|
+ val childPoint = tempPoint
|
|
+ transformPointToChildViewCoords(coords[0], coords[1], view, child, childPoint)
|
|
+ if (isClipping(child) && !isTransformedTouchPointInView(childPoint.x, childPoint.y, child)) {
|
|
+ continue
|
|
+ }
|
|
+ val restoreX = coords[0]
|
|
+ val restoreY = coords[1]
|
|
+ coords[0] = childPoint.x
|
|
+ coords[1] = childPoint.y
|
|
+ found = collectViewsAtPoint(child, coords, out)
|
|
+ coords[0] = restoreX
|
|
+ coords[1] = restoreY
|
|
+
|
|
+ if (found) {
|
|
+ break
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ // BOX_NONE views can't be the target themselves, only their children can.
|
|
+ val selfIsTarget = pointerEvents != PointerEventsConfig.BOX_NONE &&
|
|
+ isTransformedTouchPointInView(coords[0], coords[1], view)
|
|
+
|
|
+ if (found || selfIsTarget) {
|
|
+ // `out` may already contain this view when several pointers share part of their path.
|
|
+ if (!out.contains(view)) {
|
|
+ out.add(view)
|
|
+ }
|
|
+ return true
|
|
+ }
|
|
+ return false
|
|
+ }
|
|
+
|
|
private fun extractGestureHandlers(
|
|
viewGroup: ViewGroup,
|
|
coords: FloatArray,
|
|
diff --git a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
|
|
index 629c155..2efd508 100644
|
|
--- a/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
|
|
+++ b/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
|
|
@@ -19,7 +19,9 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
private val jsGestureHandler: GestureHandler?
|
|
val rootView: ViewGroup
|
|
private var shouldIntercept = false
|
|
+ private var wasIntercepting = false
|
|
private var passingTouch = false
|
|
+ private var lastTouch: MotionEvent? = null
|
|
|
|
init {
|
|
UiThreadUtil.assertOnUiThread()
|
|
@@ -47,6 +49,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
}
|
|
|
|
fun tearDown() {
|
|
+ clearLastTouch()
|
|
Log.i(
|
|
ReactConstants.TAG,
|
|
"[GESTURE HANDLER] Tearing down gesture handler registered for root view $rootView",
|
|
@@ -90,17 +93,46 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
|
|
override fun onCancel() {
|
|
shouldIntercept = true
|
|
- val time = SystemClock.uptimeMillis()
|
|
- val event = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0f, 0f, 0).apply {
|
|
- action = MotionEvent.ACTION_CANCEL
|
|
- }
|
|
if (rootView is RootView) {
|
|
- rootView.onChildStartedNativeGesture(rootView, event)
|
|
+ val cancel = createReactCancelEvent()
|
|
+ try {
|
|
+ rootView.onChildStartedNativeGesture(rootView, cancel)
|
|
+ } finally {
|
|
+ cancel.recycle()
|
|
+ clearLastTouch()
|
|
+ }
|
|
}
|
|
- event.recycle()
|
|
}
|
|
}
|
|
|
|
+ private fun clearLastTouch() {
|
|
+ lastTouch?.recycle()
|
|
+ lastTouch = null
|
|
+ }
|
|
+
|
|
+ private fun createReactCancelEvent(): MotionEvent {
|
|
+ val now = SystemClock.uptimeMillis()
|
|
+ val touch = lastTouch ?: return MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0f, 0f, 0)
|
|
+ // The enclosing React root already dispatched this event before it reached the
|
|
+ // gesture handler. A POINTER_UP is still in MotionEvent but already ended in JS.
|
|
+ val lifted = if (touch.actionMasked == MotionEvent.ACTION_POINTER_UP) touch.actionIndex else -1
|
|
+ val count = touch.pointerCount - if (lifted >= 0) 1 else 0
|
|
+ val properties = Array(count) { MotionEvent.PointerProperties() }
|
|
+ val coords = Array(count) { MotionEvent.PointerCoords() }
|
|
+ var index = 0
|
|
+ for (pointer in 0 until touch.pointerCount) {
|
|
+ if (pointer == lifted) continue
|
|
+ touch.getPointerProperties(pointer, properties[index])
|
|
+ touch.getPointerCoords(pointer, coords[index])
|
|
+ index++
|
|
+ }
|
|
+ return MotionEvent.obtain(
|
|
+ touch.downTime, now, MotionEvent.ACTION_CANCEL, count, properties, coords,
|
|
+ touch.metaState, touch.buttonState, touch.xPrecision, touch.yPrecision,
|
|
+ touch.deviceId, touch.edgeFlags, touch.source, touch.flags,
|
|
+ )
|
|
+ }
|
|
+
|
|
fun requestDisallowInterceptTouchEvent() {
|
|
// If this method gets called it means that some native view is attempting to grab lock for
|
|
// touch event delivery. In that case we cancel all gesture recognizers
|
|
@@ -115,9 +147,25 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
// We mark `mPassingTouch` before we get into `mOrchestrator.onTouchEvent` so that we can tell
|
|
// if `requestDisallow` has been called as a result of a normal gesture handling process or
|
|
// as a result of one of the gesture handlers activating
|
|
+ // Keep the stream for recognizers that activate between events (e.g. long press).
|
|
+ // Once native handling begins, React no longer receives the remaining touches.
|
|
+ if (!event.isHoverAction() && (!shouldIntercept || event.actionMasked == MotionEvent.ACTION_DOWN)) {
|
|
+ clearLastTouch()
|
|
+ if (event.actionMasked != MotionEvent.ACTION_UP && event.actionMasked != MotionEvent.ACTION_CANCEL) {
|
|
+ lastTouch = MotionEvent.obtainNoHistory(event)
|
|
+ }
|
|
+ }
|
|
passingTouch = true
|
|
orchestrator!!.onTouchEvent(event)
|
|
passingTouch = false
|
|
+
|
|
+ // On the transition into interception, cancel the native views the pointers landed on - the
|
|
+ // framework's ACTION_CANCEL never reaches them since RNGH ignores `onInterceptTouchEvent`.
|
|
+ if (shouldIntercept && !wasIntercepting) {
|
|
+ orchestrator!!.cancelTouchesInInterceptedViews(event)
|
|
+ }
|
|
+ wasIntercepting = shouldIntercept
|
|
+
|
|
return shouldIntercept
|
|
}
|
|
|
|
diff --git a/node_modules/react-native-gesture-handler/lib/commonjs/web/handlers/GestureHandler.js b/node_modules/react-native-gesture-handler/lib/commonjs/web/handlers/GestureHandler.js
|
|
index 96c5227..cbf1a88 100644
|
|
--- a/node_modules/react-native-gesture-handler/lib/commonjs/web/handlers/GestureHandler.js
|
|
+++ b/node_modules/react-native-gesture-handler/lib/commonjs/web/handlers/GestureHandler.js
|
|
@@ -58,7 +58,9 @@ class GestureHandler {
|
|
manager.setOnPointerMoveOver(this.onPointerMoveOver.bind(this));
|
|
manager.setOnPointerMoveOut(this.onPointerMoveOut.bind(this));
|
|
manager.setOnWheel(this.onWheel.bind(this));
|
|
- manager.registerListeners();
|
|
+ if (this.enabled) {
|
|
+ manager.registerListeners();
|
|
+ }
|
|
}
|
|
|
|
//
|
|
diff --git a/node_modules/react-native-gesture-handler/lib/commonjs/web/tools/PointerEventManager.js b/node_modules/react-native-gesture-handler/lib/commonjs/web/tools/PointerEventManager.js
|
|
index 76eb808..75a9d75 100644
|
|
--- a/node_modules/react-native-gesture-handler/lib/commonjs/web/tools/PointerEventManager.js
|
|
+++ b/node_modules/react-native-gesture-handler/lib/commonjs/web/tools/PointerEventManager.js
|
|
@@ -35,9 +35,6 @@ class PointerEventManager extends _EventManager.default {
|
|
}
|
|
const adaptedEvent = this.mapEvent(event, _interfaces.EventTypes.DOWN);
|
|
const target = event.target;
|
|
- if (!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
- target.setPointerCapture(adaptedEvent.pointerId);
|
|
- }
|
|
this.markAsInBounds(adaptedEvent.pointerId);
|
|
this.trackedPointers.add(adaptedEvent.pointerId);
|
|
if (++this.activePointersCounter > 1) {
|
|
@@ -46,6 +43,16 @@ class PointerEventManager extends _EventManager.default {
|
|
} else {
|
|
this.onPointerDown(adaptedEvent);
|
|
}
|
|
+
|
|
+ // Capture only a pointer the handler still tracks after seeing it. A handler that fails
|
|
+ // the pointer on down (a touch-only pan rejecting the mouse) resets, and a capture it kept
|
|
+ // would confine the browser's text selection to the pressed element.
|
|
+ if (
|
|
+ this.trackedPointers.has(adaptedEvent.pointerId) &&
|
|
+ !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)
|
|
+ ) {
|
|
+ target.setPointerCapture(adaptedEvent.pointerId);
|
|
+ }
|
|
};
|
|
pointerUpCallback = event => {
|
|
// When we call reset on gesture handlers, it also resets their event managers
|
|
@@ -58,7 +65,14 @@ class PointerEventManager extends _EventManager.default {
|
|
const adaptedEvent = this.mapEvent(event, _interfaces.EventTypes.UP);
|
|
const target = event.target;
|
|
if (!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
- target.releasePointerCapture(adaptedEvent.pointerId);
|
|
+ try {
|
|
+ if (target.hasPointerCapture(adaptedEvent.pointerId)) {
|
|
+ target.releasePointerCapture(adaptedEvent.pointerId);
|
|
+ }
|
|
+ } catch {
|
|
+ // Pointer capture is implicitly released after pointerup/pointercancel.
|
|
+ // Some browsers can report stale capture state during gesture teardown.
|
|
+ }
|
|
}
|
|
this.markAsOutOfBounds(adaptedEvent.pointerId);
|
|
this.trackedPointers.delete(adaptedEvent.pointerId);
|
|
@@ -85,7 +99,7 @@ class PointerEventManager extends _EventManager.default {
|
|
// incorporating it here seems stupid), so we just call it again here, every time
|
|
// pointer moves until it succeeds.
|
|
// God, I do love web development.
|
|
- if (!target?.hasPointerCapture(event.pointerId) && !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
+ if (this.trackedPointers.has(event.pointerId) && !target?.hasPointerCapture(event.pointerId) && !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
target.setPointerCapture(event.pointerId);
|
|
}
|
|
const inBounds = (0, _utils.isPointerInBounds)(this.view, {
|
|
diff --git a/node_modules/react-native-gesture-handler/lib/module/web/handlers/GestureHandler.js b/node_modules/react-native-gesture-handler/lib/module/web/handlers/GestureHandler.js
|
|
index 0791c66..2f41c77 100644
|
|
--- a/node_modules/react-native-gesture-handler/lib/module/web/handlers/GestureHandler.js
|
|
+++ b/node_modules/react-native-gesture-handler/lib/module/web/handlers/GestureHandler.js
|
|
@@ -52,7 +52,9 @@ export default class GestureHandler {
|
|
manager.setOnPointerMoveOver(this.onPointerMoveOver.bind(this));
|
|
manager.setOnPointerMoveOut(this.onPointerMoveOut.bind(this));
|
|
manager.setOnWheel(this.onWheel.bind(this));
|
|
- manager.registerListeners();
|
|
+ if (this.enabled) {
|
|
+ manager.registerListeners();
|
|
+ }
|
|
}
|
|
|
|
//
|
|
diff --git a/node_modules/react-native-gesture-handler/lib/module/web/tools/PointerEventManager.js b/node_modules/react-native-gesture-handler/lib/module/web/tools/PointerEventManager.js
|
|
index 6ce3b8f..65cc6c8 100644
|
|
--- a/node_modules/react-native-gesture-handler/lib/module/web/tools/PointerEventManager.js
|
|
+++ b/node_modules/react-native-gesture-handler/lib/module/web/tools/PointerEventManager.js
|
|
@@ -30,9 +30,6 @@ export default class PointerEventManager extends EventManager {
|
|
}
|
|
const adaptedEvent = this.mapEvent(event, EventTypes.DOWN);
|
|
const target = event.target;
|
|
- if (!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
- target.setPointerCapture(adaptedEvent.pointerId);
|
|
- }
|
|
this.markAsInBounds(adaptedEvent.pointerId);
|
|
this.trackedPointers.add(adaptedEvent.pointerId);
|
|
if (++this.activePointersCounter > 1) {
|
|
@@ -41,6 +38,16 @@ export default class PointerEventManager extends EventManager {
|
|
} else {
|
|
this.onPointerDown(adaptedEvent);
|
|
}
|
|
+
|
|
+ // Capture only a pointer the handler still tracks after seeing it. A handler that fails
|
|
+ // the pointer on down (a touch-only pan rejecting the mouse) resets, and a capture it kept
|
|
+ // would confine the browser's text selection to the pressed element.
|
|
+ if (
|
|
+ this.trackedPointers.has(adaptedEvent.pointerId) &&
|
|
+ !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)
|
|
+ ) {
|
|
+ target.setPointerCapture(adaptedEvent.pointerId);
|
|
+ }
|
|
};
|
|
pointerUpCallback = event => {
|
|
// When we call reset on gesture handlers, it also resets their event managers
|
|
@@ -53,7 +60,14 @@ export default class PointerEventManager extends EventManager {
|
|
const adaptedEvent = this.mapEvent(event, EventTypes.UP);
|
|
const target = event.target;
|
|
if (!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
- target.releasePointerCapture(adaptedEvent.pointerId);
|
|
+ try {
|
|
+ if (target.hasPointerCapture(adaptedEvent.pointerId)) {
|
|
+ target.releasePointerCapture(adaptedEvent.pointerId);
|
|
+ }
|
|
+ } catch {
|
|
+ // Pointer capture is implicitly released after pointerup/pointercancel.
|
|
+ // Some browsers can report stale capture state during gesture teardown.
|
|
+ }
|
|
}
|
|
this.markAsOutOfBounds(adaptedEvent.pointerId);
|
|
this.trackedPointers.delete(adaptedEvent.pointerId);
|
|
@@ -80,7 +94,7 @@ export default class PointerEventManager extends EventManager {
|
|
// incorporating it here seems stupid), so we just call it again here, every time
|
|
// pointer moves until it succeeds.
|
|
// God, I do love web development.
|
|
- if (!target?.hasPointerCapture(event.pointerId) && !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
+ if (this.trackedPointers.has(event.pointerId) && !target?.hasPointerCapture(event.pointerId) && !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
target.setPointerCapture(event.pointerId);
|
|
}
|
|
const inBounds = isPointerInBounds(this.view, {
|
|
diff --git a/node_modules/react-native-gesture-handler/src/web/handlers/GestureHandler.ts b/node_modules/react-native-gesture-handler/src/web/handlers/GestureHandler.ts
|
|
index ddb79a3..4e1274c 100644
|
|
--- a/node_modules/react-native-gesture-handler/src/web/handlers/GestureHandler.ts
|
|
+++ b/node_modules/react-native-gesture-handler/src/web/handlers/GestureHandler.ts
|
|
@@ -79,7 +79,9 @@ export default abstract class GestureHandler implements IGestureHandler {
|
|
manager.setOnPointerMoveOut(this.onPointerMoveOut.bind(this));
|
|
manager.setOnWheel(this.onWheel.bind(this));
|
|
|
|
- manager.registerListeners();
|
|
+ if (this.enabled) {
|
|
+ manager.registerListeners();
|
|
+ }
|
|
}
|
|
|
|
//
|
|
diff --git a/node_modules/react-native-gesture-handler/src/web/tools/PointerEventManager.ts b/node_modules/react-native-gesture-handler/src/web/tools/PointerEventManager.ts
|
|
index 18d3627..106b97c 100644
|
|
--- a/node_modules/react-native-gesture-handler/src/web/tools/PointerEventManager.ts
|
|
+++ b/node_modules/react-native-gesture-handler/src/web/tools/PointerEventManager.ts
|
|
@@ -39,10 +39,6 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
|
|
const adaptedEvent: AdaptedEvent = this.mapEvent(event, EventTypes.DOWN);
|
|
const target = event.target as HTMLElement;
|
|
|
|
- if (!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
- target.setPointerCapture(adaptedEvent.pointerId);
|
|
- }
|
|
-
|
|
this.markAsInBounds(adaptedEvent.pointerId);
|
|
this.trackedPointers.add(adaptedEvent.pointerId);
|
|
|
|
@@ -52,6 +48,16 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
|
|
} else {
|
|
this.onPointerDown(adaptedEvent);
|
|
}
|
|
+
|
|
+ // Capture only a pointer the handler still tracks after seeing it. A handler that fails
|
|
+ // the pointer on down (a touch-only pan rejecting the mouse) resets, and a capture it kept
|
|
+ // would confine the browser's text selection to the pressed element.
|
|
+ if (
|
|
+ this.trackedPointers.has(adaptedEvent.pointerId) &&
|
|
+ !POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)
|
|
+ ) {
|
|
+ target.setPointerCapture(adaptedEvent.pointerId);
|
|
+ }
|
|
};
|
|
|
|
private pointerUpCallback = (event: PointerEvent) => {
|
|
@@ -67,7 +73,14 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
|
|
const target = event.target as HTMLElement;
|
|
|
|
if (!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)) {
|
|
- target.releasePointerCapture(adaptedEvent.pointerId);
|
|
+ try {
|
|
+ if (target.hasPointerCapture(adaptedEvent.pointerId)) {
|
|
+ target.releasePointerCapture(adaptedEvent.pointerId);
|
|
+ }
|
|
+ } catch {
|
|
+ // Pointer capture is implicitly released after pointerup/pointercancel.
|
|
+ // Some browsers can report stale capture state during gesture teardown.
|
|
+ }
|
|
}
|
|
|
|
this.markAsOutOfBounds(adaptedEvent.pointerId);
|
|
@@ -98,6 +111,7 @@ export default class PointerEventManager extends EventManager<HTMLElement> {
|
|
// pointer moves until it succeeds.
|
|
// God, I do love web development.
|
|
if (
|
|
+ this.trackedPointers.has(event.pointerId) &&
|
|
!target?.hasPointerCapture(event.pointerId) &&
|
|
!POINTER_CAPTURE_EXCLUDE_LIST.has(target.tagName)
|
|
) {
|