forked from software-mansion/react-native-gesture-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeViewGestureHandler.js
More file actions
38 lines (36 loc) · 1.45 KB
/
NativeViewGestureHandler.js
File metadata and controls
38 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import DiscreteGestureHandler from './DiscreteGestureHandler';
import * as NodeManager from './NodeManager';
import PressGestureHandler from './PressGestureHandler';
import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
class NativeViewGestureHandler extends PressGestureHandler {
onRawEvent(ev) {
super.onRawEvent(ev);
if (!ev.isFinal) {
// if (this.ref instanceof ScrollView) {
if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
if (this.config.disallowInterruption) {
const gestures = Object.values(NodeManager.getNodes()).filter(gesture => {
const { handlerTag, view, isGestureRunning } = gesture;
return (
// Check if this gesture isn't self
handlerTag !== this.handlerTag &&
// Ensure the gesture needs to be cancelled
isGestureRunning &&
// ScrollView can cancel discrete gestures like taps and presses
gesture instanceof DiscreteGestureHandler &&
// Ensure a view exists and is a child of the current view
view &&
this.view.contains(view)
);
});
// Cancel all of the gestures that passed the filter
for (const gesture of gestures) {
// TODO: Bacon: Send some cached event.
gesture.forceInvalidate(ev);
}
}
}
}
}
}
export default NativeViewGestureHandler;