react-native-gesture-handler 1.2.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/DrawerLayout.js +5 -4
  2. package/GestureButtons.js +166 -0
  3. package/GestureComponents.js +63 -0
  4. package/GestureComponents.web.js +35 -0
  5. package/GestureHandler.js +10 -621
  6. package/GestureHandlerButton.web.js +4 -12
  7. package/GestureHandlerPropTypes.js +45 -0
  8. package/Gestures.js +278 -0
  9. package/NativeViewGestureHandler.js +14 -0
  10. package/PlatformConstants.web.js +3 -1
  11. package/RNGestureHandler.podspec +1 -1
  12. package/RNGestureHandlerModule.web.js +49 -0
  13. package/State.js +12 -1
  14. package/Swipeable.js +6 -11
  15. package/android/build.gradle +3 -7
  16. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +1 -1
  17. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +1 -1
  18. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +1 -1
  19. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +2 -2
  20. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +1 -1
  21. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +1 -1
  22. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +1 -1
  23. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +1 -1
  24. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +1 -1
  25. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +1 -1
  26. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +2 -2
  27. package/createHandler.js +46 -20
  28. package/createNativeWrapper.js +86 -0
  29. package/ios/RNGestureHandler.xcodeproj/project.pbxproj +4 -4
  30. package/package.json +20 -17
  31. package/react-native-gesture-handler.d.ts +25 -3
  32. package/touchables/GenericTouchable.js +3 -1
  33. package/touchables/TouchableHighlight.js +1 -3
  34. package/touchables/TouchableOpacity.web.js +2 -0
  35. package/touchables/TouchableWithoutFeedback.js +4 -2
  36. package/web/DiscreteGestureHandler.js +66 -0
  37. package/web/DraggingGestureHandler.js +22 -0
  38. package/web/Errors.js +5 -0
  39. package/web/FlingGestureHandler.js +137 -0
  40. package/web/GestureHandler.js +442 -0
  41. package/web/IndiscreteGestureHandler.js +33 -0
  42. package/web/LongPressGestureHandler.js +50 -0
  43. package/web/NativeViewGestureHandler.js +38 -0
  44. package/web/NodeManager.js +24 -0
  45. package/web/PanGestureHandler.js +213 -0
  46. package/web/PinchGestureHandler.js +24 -0
  47. package/web/PressGestureHandler.js +147 -0
  48. package/web/RotationGestureHandler.js +24 -0
  49. package/web/TapGestureHandler.js +160 -0
  50. package/web/constants.js +48 -0
  51. package/web/utils.js +14 -0
  52. package/Directions.web.js +0 -6
  53. package/Swipeable.web.js +0 -4
  54. package/createHandler.web.js +0 -205
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+
3
+ import NativeViewGestureHandler from './NativeViewGestureHandler';
4
+
5
+ const NATIVE_WRAPPER_BIND_BLACKLIST = new Set(['replaceState', 'isMounted']);
6
+
7
+ /*
8
+ * This array should consist of:
9
+ * - All keys in propTypes from NativeGestureHandler
10
+ * (and all keys in GestureHandlerPropTypes)
11
+ * - 'onGestureHandlerEvent'
12
+ * - 'onGestureHandlerStateChange'
13
+ */
14
+ const NATIVE_WRAPPER_PROPS_FILTER = [
15
+ 'id',
16
+ 'minPointers',
17
+ 'enabled',
18
+ 'waitFor',
19
+ 'simultaneousHandlers',
20
+ 'shouldCancelWhenOutside',
21
+ 'hitSlop',
22
+ 'onGestureEvent',
23
+ 'onHandlerStateChange',
24
+ 'onBegan',
25
+ 'onFailed',
26
+ 'onCancelled',
27
+ 'onActivated',
28
+ 'onEnded',
29
+ 'shouldActivateOnStart',
30
+ 'disallowInterruption',
31
+ 'onGestureHandlerEvent',
32
+ 'onGestureHandlerStateChange',
33
+ ];
34
+
35
+ export default function createNativeWrapper(Component, config = {}) {
36
+ class ComponentWrapper extends React.Component {
37
+ static propTypes = {
38
+ ...Component.propTypes,
39
+ };
40
+
41
+ static displayName = Component.displayName || 'ComponentWrapper';
42
+
43
+ _refHandler = node => {
44
+ // bind native component's methods
45
+ let source = node;
46
+ while (source != null) {
47
+ for (let methodName of Object.getOwnPropertyNames(source)) {
48
+ if (
49
+ !methodName.startsWith('_') && // private methods
50
+ !methodName.startsWith('component') && // lifecycle methods
51
+ !NATIVE_WRAPPER_BIND_BLACKLIST.has(methodName) && // other
52
+ typeof source[methodName] === 'function' &&
53
+ this[methodName] === undefined
54
+ ) {
55
+ if (source[methodName].prototype) {
56
+ // determine if it's not bound already
57
+ this[methodName] = source[methodName].bind(node);
58
+ } else {
59
+ this[methodName] = source[methodName];
60
+ }
61
+ }
62
+ }
63
+ source = Object.getPrototypeOf(source);
64
+ }
65
+ };
66
+
67
+ render() {
68
+ // filter out props that should be passed to gesture handler wrapper
69
+ const gestureHandlerProps = Object.keys(this.props).reduce(
70
+ (props, key) => {
71
+ if (NATIVE_WRAPPER_PROPS_FILTER.indexOf(key) !== -1) {
72
+ props[key] = this.props[key];
73
+ }
74
+ return props;
75
+ },
76
+ { ...config } // watch out not to modify config
77
+ );
78
+ return (
79
+ <NativeViewGestureHandler {...gestureHandlerProps}>
80
+ <Component {...this.props} ref={this._refHandler} />
81
+ </NativeViewGestureHandler>
82
+ );
83
+ }
84
+ }
85
+ return ComponentWrapper;
86
+ }
@@ -424,7 +424,7 @@
424
424
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
425
425
  GCC_WARN_UNUSED_FUNCTION = YES;
426
426
  GCC_WARN_UNUSED_VARIABLE = YES;
427
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
427
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
428
428
  MTL_ENABLE_DEBUG_INFO = YES;
429
429
  ONLY_ACTIVE_ARCH = YES;
430
430
  SDKROOT = iphoneos;
@@ -458,7 +458,7 @@
458
458
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
459
459
  GCC_WARN_UNUSED_FUNCTION = YES;
460
460
  GCC_WARN_UNUSED_VARIABLE = YES;
461
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
461
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
462
462
  MTL_ENABLE_DEBUG_INFO = NO;
463
463
  SDKROOT = iphoneos;
464
464
  VALIDATE_PRODUCT = YES;
@@ -524,7 +524,7 @@
524
524
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
525
525
  GCC_WARN_UNUSED_FUNCTION = YES;
526
526
  GCC_WARN_UNUSED_VARIABLE = YES;
527
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
527
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
528
528
  MTL_ENABLE_DEBUG_INFO = NO;
529
529
  SDKROOT = iphoneos;
530
530
  VALIDATE_PRODUCT = YES;
@@ -558,7 +558,7 @@
558
558
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
559
559
  GCC_WARN_UNUSED_FUNCTION = YES;
560
560
  GCC_WARN_UNUSED_VARIABLE = YES;
561
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
561
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
562
562
  MTL_ENABLE_DEBUG_INFO = NO;
563
563
  SDKROOT = iphoneos;
564
564
  VALIDATE_PRODUCT = YES;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "1.2.1",
3
+ "version": "1.4.1",
4
4
  "description": "Experimental implementation of a new declarative API for gesture handling in react-native",
5
5
  "scripts": {
6
6
  "start": "node node_modules/react-native/local-cli/cli.js start",
@@ -16,14 +16,20 @@
16
16
  "android/lib/build.gradle",
17
17
  "android/lib/src/main/java/",
18
18
  "ios/",
19
+ "web/",
19
20
  "__mocks__/",
20
21
  "touchables/**/*.js",
21
22
  "createHandler.js",
22
- "createHandler.web.js",
23
23
  "Directions.js",
24
- "Directions.web.js",
25
24
  "DrawerLayout.js",
26
25
  "GestureHandler.js",
26
+ "Gestures.js",
27
+ "GestureButtons.js",
28
+ "GestureComponents.js",
29
+ "GestureComponents.web.js",
30
+ "createNativeWrapper.js",
31
+ "GestureHandlerPropTypes.js",
32
+ "NativeViewGestureHandler.js",
27
33
  "GestureHandlerButton.js",
28
34
  "GestureHandlerButton.web.js",
29
35
  "gestureHandlerRootHOC.android.js",
@@ -35,11 +41,11 @@
35
41
  "react-native-gesture-handler.d.ts",
36
42
  "README.md",
37
43
  "RNGestureHandlerModule.js",
44
+ "RNGestureHandlerModule.web.js",
38
45
  "jestSetup.js",
39
46
  "RNGestureHandler.podspec",
40
47
  "State.js",
41
- "Swipeable.js",
42
- "Swipeable.web.js"
48
+ "Swipeable.js"
43
49
  ],
44
50
  "repository": {
45
51
  "type": "git",
@@ -56,31 +62,28 @@
56
62
  },
57
63
  "homepage": "https://github.com/kmagiera/react-native-gesture-handler#readme",
58
64
  "dependencies": {
65
+ "hammerjs": "^2.0.8",
59
66
  "hoist-non-react-statics": "^2.3.1",
60
- "invariant": "^2.2.2",
61
- "prop-types": "^15.5.10"
62
- },
63
- "peerDependencies": {
64
- "react": ">= 16.3.2",
65
- "react-native": ">= 0.58.2"
67
+ "invariant": "^2.2.4",
68
+ "prop-types": "^15.7.2"
66
69
  },
67
70
  "jest": {
68
71
  "preset": "jest-react-native"
69
72
  },
70
73
  "devDependencies": {
71
- "@types/react": "^16.0.31",
72
- "@types/react-native": "^0.51.3",
74
+ "@types/react": "^16.8.6",
75
+ "@types/react-native": "^0.60.0",
73
76
  "babel-jest": "16.0.0",
74
77
  "babel-preset-react-native": "1.9.0",
75
78
  "flow-bin": "^0.56.0",
76
79
  "husky": "^0.14.3",
77
- "jest": "16.0.2",
80
+ "jest": "^24.7.1",
78
81
  "jest-react-native": "16.0.0",
79
82
  "lint-staged": "^8.0.0-beta.1",
80
83
  "prettier": "^1.13.7",
81
- "react": "^16.3",
82
- "react-native": "^0.50.1",
83
- "react-test-renderer": "15.3.2"
84
+ "react": "^16.8.6",
85
+ "react-native": "^0.60.0",
86
+ "react-test-renderer": "16.8.6"
84
87
  },
85
88
  "lint-staged": {
86
89
  "*.js": [
@@ -225,6 +225,22 @@ declare module 'react-native-gesture-handler' {
225
225
  bottom?: number;
226
226
  vertical?: number;
227
227
  horizontal?: number;
228
+ }
229
+ | {
230
+ width: number;
231
+ left: number;
232
+ }
233
+ | {
234
+ width: number;
235
+ right: number;
236
+ }
237
+ | {
238
+ height: number;
239
+ top: number;
240
+ }
241
+ | {
242
+ height: number;
243
+ bottom: number;
228
244
  };
229
245
  }
230
246
 
@@ -362,6 +378,7 @@ declare module 'react-native-gesture-handler' {
362
378
  onPress?: (pointerInside: boolean) => void;
363
379
  onActiveStateChange?: (active: boolean) => void;
364
380
  style?: StyleProp<ViewStyle>;
381
+ rippleColor?: string;
365
382
  }
366
383
 
367
384
  export interface RectButtonProperties extends BaseButtonProperties {
@@ -426,8 +443,8 @@ declare module 'react-native-gesture-handler' {
426
443
 
427
444
  /* OTHER */
428
445
 
429
- export class FlatList extends React.Component<
430
- NativeViewGestureHandlerProperties & FlatListProperties<any>
446
+ export class FlatList<ItemT> extends React.Component<
447
+ NativeViewGestureHandlerProperties & FlatListProperties<ItemT>
431
448
  > {}
432
449
 
433
450
  export function gestureHandlerRootHOC(
@@ -442,7 +459,7 @@ declare module 'react-native-gesture-handler' {
442
459
  }
443
460
 
444
461
  declare module 'react-native-gesture-handler/Swipeable' {
445
- import { Animated } from 'react-native';
462
+ import { Animated, StyleProp, ViewStyle } from 'react-native';
446
463
 
447
464
  interface SwipeableProperties {
448
465
  friction?: number;
@@ -468,6 +485,8 @@ declare module 'react-native-gesture-handler/Swipeable' {
468
485
  dragAnimatedValue: Animated.AnimatedInterpolation
469
486
  ) => React.ReactNode;
470
487
  useNativeAnimations?: boolean;
488
+ containerStyle?: StyleProp<ViewStyle>;
489
+ childrenContainerStyle?: StyleProp<ViewStyle>;
471
490
  }
472
491
 
473
492
  export default class Swipeable extends React.Component<SwipeableProperties> {
@@ -486,6 +505,8 @@ declare module 'react-native-gesture-handler/DrawerLayout' {
486
505
 
487
506
  export type DrawerType = 'front' | 'back' | 'slide';
488
507
 
508
+ export type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';
509
+
489
510
  export type DrawerKeyboardDismissMode = 'none' | 'on-drag';
490
511
 
491
512
  export interface DrawerLayoutProperties {
@@ -495,6 +516,7 @@ declare module 'react-native-gesture-handler/DrawerLayout' {
495
516
  drawerPosition?: DrawerPosition;
496
517
  drawerWidth?: number;
497
518
  drawerBackgroundColor?: string;
519
+ drawerLockMode?: DrawerLockMode;
498
520
  keyboardDismissMode?: DrawerKeyboardDismissMode;
499
521
  onDrawerClose?: () => void;
500
522
  onDrawerOpen?: () => void;
@@ -256,7 +256,9 @@ export default class GenericTouchable extends Component {
256
256
 
257
257
  return (
258
258
  <BaseButton
259
- onHandlerStateChange={this.props.disabled ? null : this.onHandlerStateChange}
259
+ onHandlerStateChange={
260
+ this.props.disabled ? null : this.onHandlerStateChange
261
+ }
260
262
  onGestureEvent={this.onGestureEvent}
261
263
  hitSlop={this.props.hitSlop}
262
264
  {...this.props.extraButtonProps}>
@@ -27,9 +27,7 @@ export default class TouchableHighlight extends Component {
27
27
  super(props);
28
28
  this.state = {
29
29
  extraChildStyle: null,
30
- extraUnderlayStyle: {
31
- backgroundColor: props.underlayColor,
32
- },
30
+ extraUnderlayStyle: null,
33
31
  };
34
32
  }
35
33
 
@@ -0,0 +1,2 @@
1
+ import { TouchableOpacity } from 'react-native';
2
+ export default TouchableOpacity;
@@ -1,7 +1,9 @@
1
- import GenericTouchable from './GenericTouchable';
2
1
  import React from 'react';
2
+ import GenericTouchable from './GenericTouchable';
3
3
 
4
- const TouchableWithoutFeedback = props => <GenericTouchable {...props} />;
4
+ const TouchableWithoutFeedback = React.forwardRef((props, ref) => (
5
+ <GenericTouchable ref={ref} {...props} />
6
+ ));
5
7
 
6
8
  TouchableWithoutFeedback.defaultProps = GenericTouchable.defaultProps;
7
9
 
@@ -0,0 +1,66 @@
1
+ import GestureHandler from './GestureHandler';
2
+ import { TEST_MAX_IF_NOT_NAN } from './utils';
3
+
4
+ class DiscreteGestureHandler extends GestureHandler {
5
+ get isDiscrete() {
6
+ return true;
7
+ }
8
+
9
+ get shouldEnableGestureOnSetup() {
10
+ return true;
11
+ }
12
+
13
+ shouldFailUnderCustomCriteria(
14
+ { x, y, deltaX, deltaY },
15
+ { maxDeltaX, maxDeltaY, maxDistSq, shouldCancelWhenOutside }
16
+ ) {
17
+ if (shouldCancelWhenOutside) {
18
+ if (!this.isPointInView({ x, y })) {
19
+ return true;
20
+ }
21
+ }
22
+ return (
23
+ TEST_MAX_IF_NOT_NAN(Math.abs(deltaX), maxDeltaX) ||
24
+ TEST_MAX_IF_NOT_NAN(Math.abs(deltaY), maxDeltaY) ||
25
+ TEST_MAX_IF_NOT_NAN(Math.abs(deltaY * deltaY + deltaX * deltaX), maxDistSq)
26
+ );
27
+ }
28
+
29
+ transformNativeEvent({ x, y }) {
30
+ return {
31
+ absoluteX: x,
32
+ absoluteY: y,
33
+ x,
34
+ y,
35
+ };
36
+ }
37
+
38
+ isGestureEnabledForEvent(
39
+ { minPointers, maxPointers, maxDist, maxDeltaX, maxDeltaY, maxDistSq, shouldCancelWhenOutside },
40
+ recognizer,
41
+ { maxPointers: pointerLength, center, deltaX, deltaY, ...props }
42
+ ) {
43
+ const validPointerCount = pointerLength >= minPointers && pointerLength <= maxPointers;
44
+
45
+ if (
46
+ this.shouldFailUnderCustomCriteria(
47
+ { ...center, deltaX, deltaY },
48
+ {
49
+ maxDeltaX,
50
+ maxDeltaY,
51
+ maxDistSq,
52
+ shouldCancelWhenOutside,
53
+ }
54
+ ) ||
55
+ // A user probably won't land a multi-pointer tap on the first tick (so we cannot just cancel each time)
56
+ // but if the gesture is running and the user adds or subtracts another pointer then it should fail.
57
+ (!validPointerCount && this.isGestureRunning)
58
+ ) {
59
+ return { failed: true };
60
+ }
61
+
62
+ return { success: validPointerCount };
63
+ }
64
+ }
65
+
66
+ export default DiscreteGestureHandler;
@@ -0,0 +1,22 @@
1
+ import GestureHandler from './GestureHandler';
2
+
3
+ class DraggingGestureHandler extends GestureHandler {
4
+ get shouldEnableGestureOnSetup() {
5
+ return true;
6
+ }
7
+
8
+ transformNativeEvent({ deltaX, deltaY, velocityX, velocityY, center: { x, y } }) {
9
+ return {
10
+ translationX: deltaX - (this.__initialX || 0),
11
+ translationY: deltaY - (this.__initialY || 0),
12
+ absoluteX: x,
13
+ absoluteY: y,
14
+ velocityX,
15
+ velocityY,
16
+ x,
17
+ y,
18
+ };
19
+ }
20
+ }
21
+
22
+ export default DraggingGestureHandler;
package/web/Errors.js ADDED
@@ -0,0 +1,5 @@
1
+ export class GesturePropError extends Error {
2
+ constructor(name, value, expectedType) {
3
+ super(`Invalid property \`${name}: ${value}\` expected \`${expectedType}\``);
4
+ }
5
+ }
@@ -0,0 +1,137 @@
1
+ import Hammer from 'hammerjs';
2
+
3
+ import { Direction } from './constants';
4
+ import { GesturePropError } from './Errors';
5
+ import DraggingGestureHandler from './DraggingGestureHandler';
6
+ import { isnan } from './utils';
7
+
8
+ class FlingGestureHandler extends DraggingGestureHandler {
9
+ get name() {
10
+ return 'swipe';
11
+ }
12
+
13
+ get NativeGestureClass() {
14
+ return Hammer.Swipe;
15
+ }
16
+
17
+ onGestureActivated(event) {
18
+ this.sendEvent({
19
+ ...event,
20
+ eventType: Hammer.INPUT_MOVE,
21
+ isFinal: false,
22
+ isFirst: true,
23
+ });
24
+ this.isGestureRunning = false;
25
+ this.hasGestureFailed = false;
26
+ this.sendEvent({
27
+ ...event,
28
+ eventType: Hammer.INPUT_END,
29
+ isFinal: true,
30
+ });
31
+ }
32
+
33
+ onRawEvent(ev) {
34
+ super.onRawEvent(ev);
35
+ if (this.hasGestureFailed) {
36
+ return;
37
+ }
38
+ // Hammer doesn't send a `cancel` event for taps.
39
+ // Manually fail the event.
40
+ if (ev.isFinal) {
41
+ setTimeout(() => {
42
+ if (this.isGestureRunning) {
43
+ this.cancelEvent(ev);
44
+ }
45
+ });
46
+ } else if (!this.hasGestureFailed && !this.isGestureRunning) {
47
+ // Tap Gesture start event
48
+ const gesture = this.hammer.get(this.name);
49
+ if (gesture.options.enable(gesture, ev)) {
50
+ this.onStart(ev);
51
+ this.sendEvent(ev);
52
+ }
53
+ }
54
+ }
55
+
56
+ getHammerConfig() {
57
+ return {
58
+ pointers: this.config.numberOfPointers,
59
+ direction: this.getDirection(),
60
+ };
61
+ }
62
+
63
+ getTargetDirections(direction) {
64
+ const directions = [];
65
+ if (direction & Direction.RIGHT) {
66
+ directions.push(Hammer.DIRECTION_RIGHT);
67
+ }
68
+ if (direction & Direction.LEFT) {
69
+ directions.push(Hammer.DIRECTION_LEFT);
70
+ }
71
+ if (direction & Direction.UP) {
72
+ directions.push(Hammer.DIRECTION_UP);
73
+ }
74
+ if (direction & Direction.DOWN) {
75
+ directions.push(Hammer.DIRECTION_DOWN);
76
+ }
77
+ // const hammerDirection = directions.reduce((a, b) => a | b, 0);
78
+ return directions;
79
+ }
80
+
81
+ getDirection() {
82
+ const { direction } = this.getConfig();
83
+
84
+ let directions = [];
85
+ if (direction & Direction.RIGHT) {
86
+ directions.push(Hammer.DIRECTION_HORIZONTAL);
87
+ }
88
+ if (direction & Direction.LEFT) {
89
+ directions.push(Hammer.DIRECTION_HORIZONTAL);
90
+ }
91
+ if (direction & Direction.UP) {
92
+ directions.push(Hammer.DIRECTION_VERTICAL);
93
+ }
94
+ if (direction & Direction.DOWN) {
95
+ directions.push(Hammer.DIRECTION_VERTICAL);
96
+ }
97
+ directions = [...new Set(directions)];
98
+
99
+ if (directions.length === 0) return Hammer.DIRECTION_NONE;
100
+ if (directions.length === 1) return directions[0];
101
+ return Hammer.DIRECTION_ALL;
102
+ }
103
+
104
+ isGestureEnabledForEvent(
105
+ {
106
+ minPointers,
107
+ maxPointers,
108
+ numberOfPointers,
109
+ maxDist,
110
+ maxDeltaX,
111
+ maxDeltaY,
112
+ maxDistSq,
113
+ shouldCancelWhenOutside,
114
+ },
115
+ recognizer,
116
+ { maxPointers: pointerLength, deltaX: dx, deltaY: dy, ...props }
117
+ ) {
118
+ const validPointerCount = pointerLength === numberOfPointers;
119
+ if (!validPointerCount && this.isGestureRunning) {
120
+ return { failed: true };
121
+ }
122
+ return { success: validPointerCount };
123
+ }
124
+
125
+ updateGestureConfig({ numberOfPointers = 1, direction, ...props }) {
126
+ if (isnan(direction) || typeof direction !== 'number') {
127
+ throw new GesturePropError('direction', direction, 'number');
128
+ }
129
+ return super.updateGestureConfig({
130
+ numberOfPointers,
131
+ direction,
132
+ ...props,
133
+ });
134
+ }
135
+ }
136
+
137
+ export default FlingGestureHandler;