From 1bae671d80e10c1fc687d19b2fc4d44956ba90d3 Mon Sep 17 00:00:00 2001 From: Vincent Riemer Date: Fri, 24 Jun 2022 12:00:44 -0700 Subject: [PATCH] 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 --- React/Fabric/RCTSurfaceTouchHandler.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index 60fb7ae1e35..205f7fae67b 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -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