mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Refactor EventDriverAnimations to customize event match
Summary: Changelog: [Internal] - Refactor match logic on determining whether to run an EventAnimationDriver (drivers for natively animated events) for an Event dispatched. Previously, drivers were stored by key on the NativeAnimatedNodesManager (based on event handler and viewTag) and has been refactored to be stored in a list for easier matching. This diff changes it so the match logic for running an EventAnimationDriver happens on the Event instance. This change is motivated by PointerEvents needing custom match logic (done on a following change). Reviewed By: javache Differential Revision: D40691002 fbshipit-source-id: e4f6742a2af3b751214aefa1fc069f65e8e71d77
This commit is contained in:
1 parent
c565a770eb
commit
565a7439ac
3 files changed
+67
-39
No files matched your search
@@ -40,6 +40,7 @@ public abstract class Event<T extends Event> {
|
||||
private int mViewTag;
|
||||
private long mTimestampMs;
|
||||
private int mUniqueID = sUniqueID++;
|
||||
private @Nullable EventAnimationDriverMatchSpec mEventAnimationDriverMatchSpec;
|
||||
|
||||
protected Event() {}
|
||||
|
||||
@@ -165,6 +166,19 @@ public abstract class Event<T extends Event> {
|
||||
/** @return the name of this event as registered in JS */
|
||||
public abstract String getEventName();
|
||||
|
||||
public EventAnimationDriverMatchSpec getEventAnimationDriverMatchSpec() {
|
||||
if (mEventAnimationDriverMatchSpec == null) {
|
||||
mEventAnimationDriverMatchSpec =
|
||||
new EventAnimationDriverMatchSpec() {
|
||||
@Override
|
||||
public boolean match(int viewTag, String eventName) {
|
||||
return viewTag == getViewTag() && eventName.equals(getEventName());
|
||||
};
|
||||
};
|
||||
}
|
||||
return mEventAnimationDriverMatchSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch this event to JS using the given event emitter. Compatible with old and new renderer.
|
||||
* Instead of using this or dispatchModern, it is recommended that you simply override
|
||||
@@ -225,4 +239,8 @@ public abstract class Event<T extends Event> {
|
||||
}
|
||||
dispatch(rctEventEmitter);
|
||||
}
|
||||
|
||||
public interface EventAnimationDriverMatchSpec {
|
||||
boolean match(int viewTag, String eventName);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user