mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add support for pointerover and pointerout
Summary: Changelog: [Internal] - Add pointerover, pointerout events Reviewed By: vincentriemer Differential Revision: D38559454 fbshipit-source-id: 829b9f2f22e1e41a64dcce80fcc79ab9e6352dcf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
92e4ed6a28
commit
dfcd9faaad
@@ -119,6 +119,20 @@ public class JSPointerDispatcher {
|
||||
mTouchEventCoalescingKeyHelper.addCoalescingKey(mDownStartTime);
|
||||
|
||||
if (!supportsHover) {
|
||||
// Indirect OVER event dispatches before ENTER
|
||||
boolean listeningForOver =
|
||||
isAnyoneListeningForBubblingEvent(hitPath, EVENT.OVER, EVENT.OVER_CAPTURE);
|
||||
if (listeningForOver) {
|
||||
eventDispatcher.dispatchEvent(
|
||||
PointerEvent.obtain(
|
||||
PointerEventHelper.POINTER_OVER,
|
||||
surfaceId,
|
||||
activeTargetTag,
|
||||
motionEvent,
|
||||
mTargetCoordinates,
|
||||
mPrimaryPointerId));
|
||||
}
|
||||
|
||||
List<ViewTarget> enterViewTargets =
|
||||
filterByShouldDispatch(hitPath, EVENT.ENTER, EVENT.ENTER_CAPTURE, false);
|
||||
|
||||
@@ -158,6 +172,8 @@ public class JSPointerDispatcher {
|
||||
if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
mTouchEventCoalescingKeyHelper.incrementCoalescingKey(mDownStartTime);
|
||||
|
||||
// TODO(luwe) We need to fire indirect over,enter events for secondary pointers
|
||||
|
||||
boolean listeningForDown =
|
||||
isAnyoneListeningForBubblingEvent(hitPath, EVENT.DOWN, EVENT.DOWN_CAPTURE);
|
||||
if (listeningForDown) {
|
||||
@@ -198,6 +214,8 @@ public class JSPointerDispatcher {
|
||||
if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||
mTouchEventCoalescingKeyHelper.incrementCoalescingKey(mDownStartTime);
|
||||
|
||||
// TODO(luwe) We need to fire indirect out,leave events for secondary pointers
|
||||
|
||||
boolean listeningForUp =
|
||||
isAnyoneListeningForBubblingEvent(hitPath, EVENT.UP, EVENT.UP_CAPTURE);
|
||||
if (listeningForUp) {
|
||||
@@ -235,6 +253,19 @@ public class JSPointerDispatcher {
|
||||
}
|
||||
|
||||
if (!supportsHover) {
|
||||
boolean listeningForOut =
|
||||
isAnyoneListeningForBubblingEvent(hitPath, EVENT.OUT, EVENT.OUT_CAPTURE);
|
||||
if (listeningForOut) {
|
||||
eventDispatcher.dispatchEvent(
|
||||
PointerEvent.obtain(
|
||||
PointerEventHelper.POINTER_OUT,
|
||||
surfaceId,
|
||||
activeTargetTag,
|
||||
motionEvent,
|
||||
mTargetCoordinates,
|
||||
mPrimaryPointerId));
|
||||
}
|
||||
|
||||
List<ViewTarget> leaveViewTargets =
|
||||
filterByShouldDispatch(hitPath, EVENT.LEAVE, EVENT.LEAVE_CAPTURE, false);
|
||||
|
||||
@@ -408,6 +439,53 @@ public class JSPointerDispatcher {
|
||||
// If something has changed in either enter/exit, let's start a new coalescing key
|
||||
mTouchEventCoalescingKeyHelper.incrementCoalescingKey(mHoverInteractionKey);
|
||||
|
||||
// Out, Leave events
|
||||
if (mLastHitPath.size() > 0) {
|
||||
int lastTargetTag = mLastHitPath.get(0).getViewId();
|
||||
boolean listeningForOut =
|
||||
isAnyoneListeningForBubblingEvent(mLastHitPath, EVENT.OUT, EVENT.OUT_CAPTURE);
|
||||
if (listeningForOut) {
|
||||
eventDispatcher.dispatchEvent(
|
||||
PointerEvent.obtain(
|
||||
PointerEventHelper.POINTER_OUT,
|
||||
surfaceId,
|
||||
lastTargetTag,
|
||||
motionEvent,
|
||||
mTargetCoordinates,
|
||||
mPrimaryPointerId));
|
||||
}
|
||||
|
||||
// target -> root
|
||||
List<ViewTarget> leaveViewTargets =
|
||||
filterByShouldDispatch(
|
||||
mLastHitPath.subList(0, mLastHitPath.size() - firstDivergentIndexFromBack),
|
||||
EVENT.LEAVE,
|
||||
EVENT.LEAVE_CAPTURE,
|
||||
nonDivergentListeningToLeave);
|
||||
if (leaveViewTargets.size() > 0) {
|
||||
// We want to dispatch from target -> root, so no need to reverse
|
||||
dispatchEventForViewTargets(
|
||||
PointerEventHelper.POINTER_LEAVE,
|
||||
leaveViewTargets,
|
||||
eventDispatcher,
|
||||
surfaceId,
|
||||
motionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
boolean listeningForOver =
|
||||
isAnyoneListeningForBubblingEvent(hitPath, EVENT.OVER, EVENT.OVER_CAPTURE);
|
||||
if (listeningForOver) {
|
||||
eventDispatcher.dispatchEvent(
|
||||
PointerEvent.obtain(
|
||||
PointerEventHelper.POINTER_OVER,
|
||||
surfaceId,
|
||||
targetTag,
|
||||
motionEvent,
|
||||
mTargetCoordinates,
|
||||
mPrimaryPointerId));
|
||||
}
|
||||
|
||||
// target -> root
|
||||
List<ViewTarget> enterViewTargets =
|
||||
filterByShouldDispatch(
|
||||
@@ -426,23 +504,6 @@ public class JSPointerDispatcher {
|
||||
surfaceId,
|
||||
motionEvent);
|
||||
}
|
||||
|
||||
// target -> root
|
||||
List<ViewTarget> leaveViewTargets =
|
||||
filterByShouldDispatch(
|
||||
mLastHitPath.subList(0, mLastHitPath.size() - firstDivergentIndexFromBack),
|
||||
EVENT.LEAVE,
|
||||
EVENT.LEAVE_CAPTURE,
|
||||
nonDivergentListeningToLeave);
|
||||
if (leaveViewTargets.size() > 0) {
|
||||
// We want to dispatch from target -> root, so no need to reverse
|
||||
dispatchEventForViewTargets(
|
||||
PointerEventHelper.POINTER_LEAVE,
|
||||
leaveViewTargets,
|
||||
eventDispatcher,
|
||||
surfaceId,
|
||||
motionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
int coalescingKey = mTouchEventCoalescingKeyHelper.getCoalescingKey(mHoverInteractionKey);
|
||||
|
||||
Reference in New Issue
Block a user