mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN] Add public API to ReactRootView to control if JS touch events are dispatched
Summary: This diff adds flag to `ReactRootView` to control if the touch event is to be dispatched to the JS side. This is needed for subclass of `ReactRootView` to control if the dispatch is needed. Reviewed By: javache Differential Revision: D35033684 fbshipit-source-id: febab6988cc3e4259e726d03d797dd0ffc978d24
This commit is contained in:
committed by
Facebook GitHub Bot
parent
12ad1fffe8
commit
0a517ae438
@@ -234,15 +234,25 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
return true;
|
||||
}
|
||||
|
||||
// By default the JS touch events are dispatched at the root view. This can be overridden in
|
||||
// subclasses as needed.
|
||||
public boolean shouldDispatchJSTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
dispatchJSTouchEvent(ev);
|
||||
if (shouldDispatchJSTouchEvent(ev)) {
|
||||
dispatchJSTouchEvent(ev);
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
dispatchJSTouchEvent(ev);
|
||||
if (shouldDispatchJSTouchEvent(ev)) {
|
||||
dispatchJSTouchEvent(ev);
|
||||
}
|
||||
super.onTouchEvent(ev);
|
||||
// In case when there is no children interested in handling touch event, we return true from
|
||||
// the root view in order to receive subsequent events related to that gesture
|
||||
|
||||
Reference in New Issue
Block a user