Fix natively driven animated.event for bubbling PointerEvents
Summary: Changelog: [Internal] Override logic for determining whether a dispatched `Event` triggers a native `EventAnimationDriver`. Natively driven AnimatedEvents on bubbling events is not supported. `PointerEvents` requires this and this diff adds custom matching logic such that if a parent specifies an `AnimatedEvent` on `onPointerMove` and a child view dispatches it, the `AnimatedEvent` will still fire. Reviewed By: javache Differential Revision: D38722563 fbshipit-source-id: 7cde57eaff9584b33c6ab15f1fe85c0a9bac132e
This commit is contained in:
Родитель
565a7439ac
Коммит
cfe811ab18
|
@ -66,6 +66,7 @@ public class PointerEvent extends Event<PointerEvent> {
|
||||||
private short mCoalescingKey = UNSET_COALESCING_KEY;
|
private short mCoalescingKey = UNSET_COALESCING_KEY;
|
||||||
private @Nullable List<WritableMap> mPointersEventData;
|
private @Nullable List<WritableMap> mPointersEventData;
|
||||||
private PointerEventState mEventState;
|
private PointerEventState mEventState;
|
||||||
|
private @Nullable Event.EventAnimationDriverMatchSpec mEventAnimationDriverMatchSpec;
|
||||||
|
|
||||||
private void init(
|
private void init(
|
||||||
String eventName,
|
String eventName,
|
||||||
|
@ -114,6 +115,31 @@ public class PointerEvent extends Event<PointerEvent> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Event.EventAnimationDriverMatchSpec getEventAnimationDriverMatchSpec() {
|
||||||
|
if (mEventAnimationDriverMatchSpec == null) {
|
||||||
|
mEventAnimationDriverMatchSpec =
|
||||||
|
new EventAnimationDriverMatchSpec() {
|
||||||
|
@Override
|
||||||
|
public boolean match(int viewTag, String eventName) {
|
||||||
|
if (!PointerEventHelper.isBubblingEvent(eventName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TouchTargetHelper.ViewTarget> viewTargets =
|
||||||
|
mEventState.getHitPathForActivePointer();
|
||||||
|
for (TouchTargetHelper.ViewTarget viewTarget : viewTargets) {
|
||||||
|
if (viewTarget.getViewId() == viewTag && eventName.equals(mEventName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return mEventAnimationDriverMatchSpec;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDispose() {
|
public void onDispose() {
|
||||||
mPointersEventData = null;
|
mPointersEventData = null;
|
||||||
|
@ -329,5 +355,9 @@ public class PointerEvent extends Event<PointerEvent> {
|
||||||
public final Map<Integer, float[]> getEventCoordinatesByPointerId() {
|
public final Map<Integer, float[]> getEventCoordinatesByPointerId() {
|
||||||
return mEventCoordinatesByPointerId;
|
return mEventCoordinatesByPointerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final List<TouchTargetHelper.ViewTarget> getHitPathForActivePointer() {
|
||||||
|
return mHitPathByPointerId.get(mActivePointerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,4 +212,18 @@ public class PointerEventHelper {
|
||||||
boolean inActiveButtonState = buttonState != 0;
|
boolean inActiveButtonState = buttonState != 0;
|
||||||
return inActiveButtonState ? 0.5 : 0;
|
return inActiveButtonState ? 0.5 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBubblingEvent(String eventName) {
|
||||||
|
switch (eventName) {
|
||||||
|
case POINTER_UP:
|
||||||
|
case POINTER_DOWN:
|
||||||
|
case POINTER_OVER:
|
||||||
|
case POINTER_OUT:
|
||||||
|
case POINTER_MOVE:
|
||||||
|
case POINTER_CANCEL:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче