Emit move PointerEvents for hover

Summary:
Changelog: [iOS][Internal] - Emit move PointerEvents when hovering with an indirect pointer

This diff ensures that when a user is hovering an RN app w/ an indirect pointer (mouse/trackpad/ect.) that `pointermove` events are emitted. Previously `pointermove` was only fired on touch interactions on iOS.

Reviewed By: lunaleaps

Differential Revision: D37353158

fbshipit-source-id: 30366324ea10c91a38dbbc1be1032c021fd8a0e0
This commit is contained in:
Vincent Riemer
2022-06-24 12:00:44 -07:00
committed by Facebook GitHub Bot
parent fb57929f22
commit 1bae671d80
+15
View File
@@ -651,6 +651,8 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
NSTimeInterval timestamp = CACurrentMediaTime();
BOOL hasMoveListenerInEventPath = NO;
// Over
if (prevTargetView != targetView) {
BOOL shouldEmitOverEvent = IsAnyViewInPathListeningToEvent(eventPathViews, ViewEvents::Offset::PointerOver);
@@ -686,6 +688,19 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
if (shouldEmitEvent && !hasParentEnterListener) {
hasParentEnterListener = YES;
}
if (!hasMoveListenerInEventPath && IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerMove2)) {
hasMoveListenerInEventPath = YES;
}
}
// Moving
if (hasMoveListenerInEventPath) {
SharedTouchEventEmitter eventEmitter = GetTouchEmitterFromView(targetView, [recognizer locationInView:targetView]);
if (eventEmitter != nil) {
PointerEvent event = CreatePointerEventFromIncompleteHoverData(targetView, clientLocation, timestamp);
eventEmitter->onPointerMove2(event);
}
}
// Out