react-native-gesture-handler 2.7.0 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/handlers/gestures/GestureDetector.js +9 -2
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureComposition.js +15 -4
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +18 -14
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +8 -4
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +2 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +1 -4
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -2
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +9 -2
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/gestureComposition.js +15 -4
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +18 -14
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +8 -3
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +2 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +1 -4
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +2 -2
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
- package/package.json +1 -1
- package/src/handlers/gestures/GestureDetector.tsx +10 -3
- package/src/handlers/gestures/gestureComposition.ts +19 -6
- package/src/web/handlers/FlingGestureHandler.ts +26 -17
- package/src/web/handlers/GestureHandler.ts +12 -6
- package/src/web/handlers/LongPressGestureHandler.ts +2 -0
- package/src/web/handlers/NativeViewGestureHandler.ts +1 -4
- package/src/web/handlers/PanGestureHandler.ts +2 -2
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
@@ -69,14 +69,24 @@ export class ComposedGesture extends Gesture {
|
|
69
69
|
|
70
70
|
export class SimultaneousGesture extends ComposedGesture {
|
71
71
|
prepare() {
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
// this piece of magic works something like this:
|
73
|
+
// for every gesture in the array
|
74
|
+
const simultaneousArrays = this.gestures.map((gesture) =>
|
75
|
+
// we take the array it's in
|
76
|
+
this.gestures
|
77
|
+
// and make a copy without it
|
78
|
+
.filter((x) => x !== gesture)
|
79
|
+
// then we flatmap the result to get list of raw (not composed) gestures
|
80
|
+
// this way we don't make the gestures simultaneous with themselves, which is
|
81
|
+
// important when the gesture is `ExclusiveGesture` - we don't want to make
|
82
|
+
// exclusive gestures simultaneous
|
83
|
+
.flatMap((x) => x.toGestureArray())
|
84
|
+
);
|
75
85
|
|
76
|
-
for (
|
86
|
+
for (let i = 0; i < this.gestures.length; i++) {
|
77
87
|
this.prepareSingleGesture(
|
78
|
-
|
79
|
-
|
88
|
+
this.gestures[i],
|
89
|
+
simultaneousArrays[i],
|
80
90
|
this.requireGesturesToFail
|
81
91
|
);
|
82
92
|
}
|
@@ -85,6 +95,8 @@ export class SimultaneousGesture extends ComposedGesture {
|
|
85
95
|
|
86
96
|
export class ExclusiveGesture extends ComposedGesture {
|
87
97
|
prepare() {
|
98
|
+
// transforms the array of gestures into array of grouped raw (not composed) gestures
|
99
|
+
// i.e. [gesture1, gesture2, ComposedGesture(gesture3, gesture4)] -> [[gesture1], [gesture2], [gesture3, gesture4]]
|
88
100
|
const gestureArrays = this.gestures.map((gesture) =>
|
89
101
|
gesture.toGestureArray()
|
90
102
|
);
|
@@ -98,6 +110,7 @@ export class ExclusiveGesture extends ComposedGesture {
|
|
98
110
|
this.requireGesturesToFail.concat(requireToFail)
|
99
111
|
);
|
100
112
|
|
113
|
+
// every group gets to wait for all groups before it
|
101
114
|
requireToFail = requireToFail.concat(gestureArrays[i]);
|
102
115
|
}
|
103
116
|
}
|
@@ -21,6 +21,7 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
21
21
|
private startY = 0;
|
22
22
|
|
23
23
|
private maxNumberOfPointersSimultaneously = 0;
|
24
|
+
private keyPointer = NaN;
|
24
25
|
|
25
26
|
public init(ref: number, propsRef: React.RefObject<unknown>): void {
|
26
27
|
super.init(ref, propsRef);
|
@@ -51,9 +52,9 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
51
52
|
};
|
52
53
|
}
|
53
54
|
|
54
|
-
private startFling(
|
55
|
-
this.startX =
|
56
|
-
this.startY =
|
55
|
+
private startFling(): void {
|
56
|
+
this.startX = this.tracker.getLastX(this.keyPointer);
|
57
|
+
this.startY = this.tracker.getLastY(this.keyPointer);
|
57
58
|
|
58
59
|
this.begin();
|
59
60
|
|
@@ -62,18 +63,22 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
62
63
|
this.delayTimeout = setTimeout(() => this.fail(), this.maxDurationMs);
|
63
64
|
}
|
64
65
|
|
65
|
-
private tryEndFling(
|
66
|
+
private tryEndFling(): boolean {
|
66
67
|
if (
|
67
68
|
this.maxNumberOfPointersSimultaneously ===
|
68
69
|
this.numberOfPointersRequired &&
|
69
70
|
((this.direction & Direction.RIGHT &&
|
70
|
-
|
71
|
+
this.tracker.getLastX(this.keyPointer) - this.startX >
|
72
|
+
this.minAcceptableDelta) ||
|
71
73
|
(this.direction & Direction.LEFT &&
|
72
|
-
this.startX -
|
74
|
+
this.startX - this.tracker.getLastX(this.keyPointer) >
|
75
|
+
this.minAcceptableDelta) ||
|
73
76
|
(this.direction & Direction.UP &&
|
74
|
-
this.startY -
|
77
|
+
this.startY - this.tracker.getLastY(this.keyPointer) >
|
78
|
+
this.minAcceptableDelta) ||
|
75
79
|
(this.direction & Direction.DOWN &&
|
76
|
-
|
80
|
+
this.tracker.getLastY(this.keyPointer) - this.startY >
|
81
|
+
this.minAcceptableDelta))
|
77
82
|
) {
|
78
83
|
clearTimeout(this.delayTimeout);
|
79
84
|
this.activate();
|
@@ -84,34 +89,36 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
84
89
|
return false;
|
85
90
|
}
|
86
91
|
|
87
|
-
private endFling(
|
88
|
-
if (!this.tryEndFling(
|
92
|
+
private endFling() {
|
93
|
+
if (!this.tryEndFling()) {
|
89
94
|
this.fail();
|
90
95
|
}
|
91
96
|
}
|
92
97
|
|
93
98
|
protected onPointerDown(event: AdaptedEvent): void {
|
94
99
|
this.tracker.addToTracker(event);
|
100
|
+
this.keyPointer = event.pointerId;
|
101
|
+
|
95
102
|
super.onPointerDown(event);
|
96
|
-
this.newPointerAction(
|
103
|
+
this.newPointerAction();
|
97
104
|
}
|
98
105
|
|
99
106
|
protected onPointerAdd(event: AdaptedEvent): void {
|
100
107
|
this.tracker.addToTracker(event);
|
101
108
|
super.onPointerAdd(event);
|
102
|
-
this.newPointerAction(
|
109
|
+
this.newPointerAction();
|
103
110
|
}
|
104
111
|
|
105
|
-
private newPointerAction(
|
112
|
+
private newPointerAction(): void {
|
106
113
|
if (this.currentState === State.UNDETERMINED) {
|
107
|
-
this.startFling(
|
114
|
+
this.startFling();
|
108
115
|
}
|
109
116
|
|
110
117
|
if (this.currentState !== State.BEGAN) {
|
111
118
|
return;
|
112
119
|
}
|
113
120
|
|
114
|
-
this.tryEndFling(
|
121
|
+
this.tryEndFling();
|
115
122
|
|
116
123
|
if (
|
117
124
|
this.tracker.getTrackedPointersCount() >
|
@@ -128,7 +135,7 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
128
135
|
return;
|
129
136
|
}
|
130
137
|
|
131
|
-
this.tryEndFling(
|
138
|
+
this.tryEndFling();
|
132
139
|
|
133
140
|
super.onPointerMove(event);
|
134
141
|
}
|
@@ -136,6 +143,8 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
136
143
|
protected onPointerUp(event: AdaptedEvent): void {
|
137
144
|
super.onPointerUp(event);
|
138
145
|
this.onUp(event);
|
146
|
+
|
147
|
+
this.keyPointer = NaN;
|
139
148
|
}
|
140
149
|
|
141
150
|
protected onPointerRemove(event: AdaptedEvent): void {
|
@@ -148,7 +157,7 @@ export default class FlingGestureHandler extends GestureHandler {
|
|
148
157
|
if (this.currentState !== State.BEGAN) {
|
149
158
|
return;
|
150
159
|
}
|
151
|
-
this.endFling(
|
160
|
+
this.endFling();
|
152
161
|
}
|
153
162
|
|
154
163
|
protected onPointerCancel(event: AdaptedEvent): void {
|
@@ -121,19 +121,17 @@ export default abstract class GestureHandler {
|
|
121
121
|
return;
|
122
122
|
}
|
123
123
|
|
124
|
+
const oldState = this.currentState;
|
125
|
+
this.currentState = newState;
|
126
|
+
|
124
127
|
if (
|
125
128
|
this.tracker.getTrackedPointersCount() > 0 &&
|
126
129
|
this.config.needsPointerData &&
|
127
|
-
(
|
128
|
-
newState === State.CANCELLED ||
|
129
|
-
newState === State.FAILED)
|
130
|
+
this.isFinished()
|
130
131
|
) {
|
131
132
|
this.cancelTouches();
|
132
133
|
}
|
133
134
|
|
134
|
-
const oldState = this.currentState;
|
135
|
-
this.currentState = newState;
|
136
|
-
|
137
135
|
GestureHandlerOrchestrator.getInstance().onHandlerStateChange(
|
138
136
|
this,
|
139
137
|
newState,
|
@@ -775,6 +773,14 @@ export default abstract class GestureHandler {
|
|
775
773
|
return this.enabled;
|
776
774
|
}
|
777
775
|
|
776
|
+
private isFinished(): boolean {
|
777
|
+
return (
|
778
|
+
this.currentState === State.END ||
|
779
|
+
this.currentState === State.FAILED ||
|
780
|
+
this.currentState === State.CANCELLED
|
781
|
+
);
|
782
|
+
}
|
783
|
+
|
778
784
|
protected setShouldCancelWhenOutside(shouldCancel: boolean) {
|
779
785
|
this.shouldCancellWhenOutside = shouldCancel;
|
780
786
|
}
|
@@ -23,6 +23,8 @@ export default class LongPressGestureHandler extends GestureHandler {
|
|
23
23
|
public init(ref: number, propsRef: React.RefObject<unknown>) {
|
24
24
|
super.init(ref, propsRef);
|
25
25
|
this.setShouldCancelWhenOutside(true);
|
26
|
+
|
27
|
+
this.view.oncontextmenu = () => false;
|
26
28
|
}
|
27
29
|
|
28
30
|
protected transformNativeEvent() {
|
@@ -29,11 +29,8 @@ export default class NativeViewGestureHandler extends GestureHandler {
|
|
29
29
|
this.buttonRole = true;
|
30
30
|
} else {
|
31
31
|
this.buttonRole = false;
|
32
|
-
}
|
33
|
-
|
34
|
-
if (this.view.tagName.toLowerCase() === 'input') {
|
35
|
-
//Enables text input on Safari
|
36
32
|
this.view.style['webkitUserSelect'] = 'auto';
|
33
|
+
this.view.style['userSelect'] = 'auto';
|
37
34
|
}
|
38
35
|
}
|
39
36
|
|
@@ -98,8 +98,8 @@ export default class PanGestureHandler extends GestureHandler {
|
|
98
98
|
this.activateAfterLongPress = this.config.activateAfterLongPress;
|
99
99
|
}
|
100
100
|
|
101
|
-
if (this.config.shouldCancelWhenOutside) {
|
102
|
-
this.setShouldCancelWhenOutside(
|
101
|
+
if (this.config.shouldCancelWhenOutside !== undefined) {
|
102
|
+
this.setShouldCancelWhenOutside(this.config.shouldCancelWhenOutside);
|
103
103
|
}
|
104
104
|
|
105
105
|
if (this.config.activeOffsetXStart !== undefined) {
|
Binary file
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>SchemeUserState</key>
|
6
|
-
<dict>
|
7
|
-
<key>RNGestureHandler-tvOS.xcscheme_^#shared#^_</key>
|
8
|
-
<dict>
|
9
|
-
<key>orderHint</key>
|
10
|
-
<integer>0</integer>
|
11
|
-
</dict>
|
12
|
-
<key>RNGestureHandler.xcscheme_^#shared#^_</key>
|
13
|
-
<dict>
|
14
|
-
<key>orderHint</key>
|
15
|
-
<integer>1</integer>
|
16
|
-
</dict>
|
17
|
-
</dict>
|
18
|
-
</dict>
|
19
|
-
</plist>
|