react-native-gesture-handler 2.16.0 → 2.16.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +9 -3
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +15 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js +13 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +17 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +135 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js +66 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/longPressGesture.js +12 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js +10 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js +76 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/tapGesture.js +42 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/commonjs/utils.js +5 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +7 -7
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +3 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +9 -3
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +15 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js +13 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +17 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +135 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js +12 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js +10 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js +76 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/tapGesture.js +42 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/module/utils.js +5 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +7 -7
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +3 -1
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/typescript/handlers/PanGestureHandler.d.ts +4 -4
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +36 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +11 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +14 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +113 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +57 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +10 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +8 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +67 -4
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +35 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -2
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -1
- package/lib/typescript/web/interfaces.d.ts +1 -0
- package/package.json +3 -2
- package/src/handlers/PanGestureHandler.ts +8 -4
- package/src/handlers/createHandler.tsx +14 -10
- package/src/handlers/gestures/GestureDetector.tsx +38 -0
- package/src/handlers/gestures/flingGesture.ts +11 -0
- package/src/handlers/gestures/forceTouchGesture.ts +14 -0
- package/src/handlers/gestures/gesture.ts +113 -0
- package/src/handlers/gestures/gestureObjects.ts +57 -0
- package/src/handlers/gestures/gestureStateManager.web.ts +1 -1
- package/src/handlers/gestures/hoverGesture.ts +1 -1
- package/src/handlers/gestures/longPressGesture.ts +10 -0
- package/src/handlers/gestures/nativeGesture.ts +8 -0
- package/src/handlers/gestures/panGesture.ts +75 -4
- package/src/handlers/gestures/tapGesture.ts +35 -0
- package/src/utils.ts +9 -2
- package/src/web/handlers/GestureHandler.ts +9 -9
- package/src/web/handlers/IGestureHandler.ts +1 -1
- package/src/web/handlers/PanGestureHandler.ts +4 -0
- package/src/web/interfaces.ts +1 -0
@@ -37,16 +37,33 @@ class ForceTouchGesture extends _gesture.ContinousBaseGesture {
|
|
37
37
|
|
38
38
|
this.handlerName = 'ForceTouchGestureHandler';
|
39
39
|
}
|
40
|
+
/**
|
41
|
+
* A minimal pressure that is required before gesture can activate.
|
42
|
+
* Should be a value from range [0.0, 1.0]. Default is 0.2.
|
43
|
+
* @param force
|
44
|
+
*/
|
45
|
+
|
40
46
|
|
41
47
|
minForce(force) {
|
42
48
|
this.config.minForce = force;
|
43
49
|
return this;
|
44
50
|
}
|
51
|
+
/**
|
52
|
+
* A maximal pressure that could be applied for gesture.
|
53
|
+
* If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].
|
54
|
+
* @param force
|
55
|
+
*/
|
56
|
+
|
45
57
|
|
46
58
|
maxForce(force) {
|
47
59
|
this.config.maxForce = force;
|
48
60
|
return this;
|
49
61
|
}
|
62
|
+
/**
|
63
|
+
* Value defining if haptic feedback has to be performed on activation.
|
64
|
+
* @param value
|
65
|
+
*/
|
66
|
+
|
50
67
|
|
51
68
|
feedbackOnActivation(value) {
|
52
69
|
this.config.feedbackOnActivation = value;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["forceTouchGesture.ts"],"names":["changeEventCalculator","current","previous","changePayload","undefined","forceChange","force","ForceTouchGesture","ContinousBaseGesture","constructor","handlerName","minForce","config","maxForce","feedbackOnActivation","value","onChange","callback","handlers"],"mappings":";;;;;;;AAAA;;;;AAWA,SAASA,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAEM,MAAMI,iBAAN,SAAgCC,6BAAhC,CAGL;AAGAC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD
|
1
|
+
{"version":3,"sources":["forceTouchGesture.ts"],"names":["changeEventCalculator","current","previous","changePayload","undefined","forceChange","force","ForceTouchGesture","ContinousBaseGesture","constructor","handlerName","minForce","config","maxForce","feedbackOnActivation","value","onChange","callback","handlers"],"mappings":";;;;;;;AAAA;;;;AAWA,SAASA,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAEM,MAAMI,iBAAN,SAAgCC,6BAAhC,CAGL;AAGAC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,QAAQ,CAACL,KAAD,EAAgB;AACtB,SAAKM,MAAL,CAAYD,QAAZ,GAAuBL,KAAvB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEO,EAAAA,QAAQ,CAACP,KAAD,EAAgB;AACtB,SAAKM,MAAL,CAAYC,QAAZ,GAAuBP,KAAvB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;;;AACEQ,EAAAA,oBAAoB,CAACC,KAAD,EAAiB;AACnC,SAAKH,MAAL,CAAYE,oBAAZ,GAAmCC,KAAnC;AACA,WAAO,IAAP;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EASN;AACA;AACA,SAAKC,QAAL,CAAclB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMgB,QAAN,CAAeC,QAAf,CAAP;AACD;;AAnDD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport {\n ForceTouchGestureConfig,\n ForceTouchGestureHandlerEventPayload,\n} from '../ForceTouchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type ForceTouchGestureChangeEventPayload = {\n forceChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: ForceTouchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n forceChange: current.force,\n };\n } else {\n changePayload = {\n forceChange: current.force - previous.force,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class ForceTouchGesture extends ContinousBaseGesture<\n ForceTouchGestureHandlerEventPayload,\n ForceTouchGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & ForceTouchGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'ForceTouchGestureHandler';\n }\n\n /**\n * A minimal pressure that is required before gesture can activate.\n * Should be a value from range [0.0, 1.0]. Default is 0.2.\n * @param force\n */\n minForce(force: number) {\n this.config.minForce = force;\n return this;\n }\n\n /**\n * A maximal pressure that could be applied for gesture.\n * If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].\n * @param force\n */\n maxForce(force: number) {\n this.config.maxForce = force;\n return this;\n }\n\n /**\n * Value defining if haptic feedback has to be performed on activation.\n * @param value\n */\n feedbackOnActivation(value: boolean) {\n this.config.feedbackOnActivation = value;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n GestureUpdateEvent<\n ForceTouchGestureHandlerEventPayload &\n ForceTouchGestureChangeEventPayload\n >\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;\n"]}
|
@@ -63,6 +63,11 @@ class BaseGesture extends Gesture {
|
|
63
63
|
const value = this.config[key];
|
64
64
|
this.config[key] = value ? Array().concat(value, gesture) : [gesture];
|
65
65
|
}
|
66
|
+
/**
|
67
|
+
* Sets a `ref` to the gesture object, allowing for interoperability with the old API.
|
68
|
+
* @param ref
|
69
|
+
*/
|
70
|
+
|
66
71
|
|
67
72
|
withRef(ref) {
|
68
73
|
this.config.ref = ref;
|
@@ -74,18 +79,35 @@ class BaseGesture extends Gesture {
|
|
74
79
|
//@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
75
80
|
return callback.__workletHash !== undefined;
|
76
81
|
}
|
82
|
+
/**
|
83
|
+
* Set the callback that is being called when given gesture handler starts receiving touches.
|
84
|
+
* At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.
|
85
|
+
* @param callback
|
86
|
+
*/
|
87
|
+
|
77
88
|
|
78
89
|
onBegin(callback) {
|
79
90
|
this.handlers.onBegin = callback;
|
80
91
|
this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
|
81
92
|
return this;
|
82
93
|
}
|
94
|
+
/**
|
95
|
+
* Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.
|
96
|
+
* @param callback
|
97
|
+
*/
|
98
|
+
|
83
99
|
|
84
100
|
onStart(callback) {
|
85
101
|
this.handlers.onStart = callback;
|
86
102
|
this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
|
87
103
|
return this;
|
88
104
|
}
|
105
|
+
/**
|
106
|
+
* Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.
|
107
|
+
* It will be called only if the handler was previously in the `ACTIVE` state.
|
108
|
+
* @param callback
|
109
|
+
*/
|
110
|
+
|
89
111
|
|
90
112
|
onEnd(callback) {
|
91
113
|
this.handlers.onEnd = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
@@ -93,6 +115,11 @@ class BaseGesture extends Gesture {
|
|
93
115
|
this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);
|
94
116
|
return this;
|
95
117
|
}
|
118
|
+
/**
|
119
|
+
* Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
|
120
|
+
* @param callback
|
121
|
+
*/
|
122
|
+
|
96
123
|
|
97
124
|
onFinalize(callback) {
|
98
125
|
this.handlers.onFinalize = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
@@ -100,6 +127,11 @@ class BaseGesture extends Gesture {
|
|
100
127
|
this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
|
101
128
|
return this;
|
102
129
|
}
|
130
|
+
/**
|
131
|
+
* Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.
|
132
|
+
* @param callback
|
133
|
+
*/
|
134
|
+
|
103
135
|
|
104
136
|
onTouchesDown(callback) {
|
105
137
|
this.config.needsPointerData = true;
|
@@ -107,6 +139,11 @@ class BaseGesture extends Gesture {
|
|
107
139
|
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] = this.isWorklet(callback);
|
108
140
|
return this;
|
109
141
|
}
|
142
|
+
/**
|
143
|
+
* Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.
|
144
|
+
* @param callback
|
145
|
+
*/
|
146
|
+
|
110
147
|
|
111
148
|
onTouchesMove(callback) {
|
112
149
|
this.config.needsPointerData = true;
|
@@ -114,6 +151,11 @@ class BaseGesture extends Gesture {
|
|
114
151
|
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] = this.isWorklet(callback);
|
115
152
|
return this;
|
116
153
|
}
|
154
|
+
/**
|
155
|
+
* Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.
|
156
|
+
* @param callback
|
157
|
+
*/
|
158
|
+
|
117
159
|
|
118
160
|
onTouchesUp(callback) {
|
119
161
|
this.config.needsPointerData = true;
|
@@ -121,6 +163,11 @@ class BaseGesture extends Gesture {
|
|
121
163
|
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] = this.isWorklet(callback);
|
122
164
|
return this;
|
123
165
|
}
|
166
|
+
/**
|
167
|
+
* Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.
|
168
|
+
* @param callback
|
169
|
+
*/
|
170
|
+
|
124
171
|
|
125
172
|
onTouchesCancelled(callback) {
|
126
173
|
this.config.needsPointerData = true;
|
@@ -128,36 +175,84 @@ class BaseGesture extends Gesture {
|
|
128
175
|
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] = this.isWorklet(callback);
|
129
176
|
return this;
|
130
177
|
}
|
178
|
+
/**
|
179
|
+
* Indicates whether the given handler should be analyzing stream of touch events or not.
|
180
|
+
* @param enabled
|
181
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean
|
182
|
+
*/
|
183
|
+
|
131
184
|
|
132
185
|
enabled(enabled) {
|
133
186
|
this.config.enabled = enabled;
|
134
187
|
return this;
|
135
188
|
}
|
189
|
+
/**
|
190
|
+
* When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.
|
191
|
+
* @param value
|
192
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean
|
193
|
+
*/
|
194
|
+
|
136
195
|
|
137
196
|
shouldCancelWhenOutside(value) {
|
138
197
|
this.config.shouldCancelWhenOutside = value;
|
139
198
|
return this;
|
140
199
|
}
|
200
|
+
/**
|
201
|
+
* This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.
|
202
|
+
* When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
|
203
|
+
* @param hitSlop
|
204
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings
|
205
|
+
*/
|
206
|
+
|
141
207
|
|
142
208
|
hitSlop(hitSlop) {
|
143
209
|
this.config.hitSlop = hitSlop;
|
144
210
|
return this;
|
145
211
|
}
|
212
|
+
/**
|
213
|
+
* #### Web only
|
214
|
+
* This parameter allows to specify which `cursor` should be used when gesture activates.
|
215
|
+
* Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
|
216
|
+
* @param activeCursor
|
217
|
+
*/
|
218
|
+
|
146
219
|
|
147
220
|
activeCursor(activeCursor) {
|
148
221
|
this.config.activeCursor = activeCursor;
|
149
222
|
return this;
|
150
223
|
}
|
224
|
+
/**
|
225
|
+
* #### Web & Android only
|
226
|
+
* Allows users to choose which mouse button should handler respond to.
|
227
|
+
* Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.
|
228
|
+
* Default value is set to `MouseButton.LEFT`.
|
229
|
+
* @param mouseButton
|
230
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only
|
231
|
+
*/
|
232
|
+
|
151
233
|
|
152
234
|
mouseButton(mouseButton) {
|
153
235
|
this.config.mouseButton = mouseButton;
|
154
236
|
return this;
|
155
237
|
}
|
238
|
+
/**
|
239
|
+
* When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.
|
240
|
+
* This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
|
241
|
+
* Defaults to `false`.
|
242
|
+
* @param runOnJS
|
243
|
+
*/
|
244
|
+
|
156
245
|
|
157
246
|
runOnJS(runOnJS) {
|
158
247
|
this.config.runOnJS = runOnJS;
|
159
248
|
return this;
|
160
249
|
}
|
250
|
+
/**
|
251
|
+
* Allows gestures across different components to be recognized simultaneously.
|
252
|
+
* @param gestures
|
253
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture
|
254
|
+
*/
|
255
|
+
|
161
256
|
|
162
257
|
simultaneousWithExternalGesture(...gestures) {
|
163
258
|
for (const gesture of gestures) {
|
@@ -166,6 +261,12 @@ class BaseGesture extends Gesture {
|
|
166
261
|
|
167
262
|
return this;
|
168
263
|
}
|
264
|
+
/**
|
265
|
+
* Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).
|
266
|
+
* @param gestures
|
267
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail
|
268
|
+
*/
|
269
|
+
|
169
270
|
|
170
271
|
requireExternalGestureToFail(...gestures) {
|
171
272
|
for (const gesture of gestures) {
|
@@ -174,6 +275,12 @@ class BaseGesture extends Gesture {
|
|
174
275
|
|
175
276
|
return this;
|
176
277
|
}
|
278
|
+
/**
|
279
|
+
* Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.
|
280
|
+
* @param gestures
|
281
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture
|
282
|
+
*/
|
283
|
+
|
177
284
|
|
178
285
|
blocksExternalGesture(...gestures) {
|
179
286
|
for (const gesture of gestures) {
|
@@ -182,11 +289,23 @@ class BaseGesture extends Gesture {
|
|
182
289
|
|
183
290
|
return this;
|
184
291
|
}
|
292
|
+
/**
|
293
|
+
* Sets a `testID` property for gesture object, allowing for querying for it in tests.
|
294
|
+
* @param id
|
295
|
+
*/
|
296
|
+
|
185
297
|
|
186
298
|
withTestId(id) {
|
187
299
|
this.config.testId = id;
|
188
300
|
return this;
|
189
301
|
}
|
302
|
+
/**
|
303
|
+
* #### iOS only
|
304
|
+
* When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.
|
305
|
+
* Default value is `true`.
|
306
|
+
* @param value
|
307
|
+
*/
|
308
|
+
|
190
309
|
|
191
310
|
cancelsTouchesInView(value) {
|
192
311
|
this.config.cancelsTouchesInView = value;
|
@@ -223,17 +342,33 @@ class BaseGesture extends Gesture {
|
|
223
342
|
exports.BaseGesture = BaseGesture;
|
224
343
|
|
225
344
|
class ContinousBaseGesture extends BaseGesture {
|
345
|
+
/**
|
346
|
+
* Set the callback that is being called every time the gesture receives an update while it's active.
|
347
|
+
* @param callback
|
348
|
+
*/
|
226
349
|
onUpdate(callback) {
|
227
350
|
this.handlers.onUpdate = callback;
|
228
351
|
this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
|
229
352
|
return this;
|
230
353
|
}
|
354
|
+
/**
|
355
|
+
* Set the callback that is being called every time the gesture receives an update while it's active.
|
356
|
+
* This callback will receive information about change in value in relation to the last received event.
|
357
|
+
* @param callback
|
358
|
+
*/
|
359
|
+
|
231
360
|
|
232
361
|
onChange(callback) {
|
233
362
|
this.handlers.onChange = callback;
|
234
363
|
this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);
|
235
364
|
return this;
|
236
365
|
}
|
366
|
+
/**
|
367
|
+
* When `true` the handler will not activate by itself even if its activation criteria are met.
|
368
|
+
* Instead you can manipulate its state using state manager.
|
369
|
+
* @param manualActivation
|
370
|
+
*/
|
371
|
+
|
237
372
|
|
238
373
|
manualActivation(manualActivation) {
|
239
374
|
this.config.manualActivation = manualActivation;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gesture.ts"],"names":["CALLBACK_TYPE","UNDEFINED","BEGAN","START","UPDATE","CHANGE","END","FINALIZE","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED","Gesture","nextGestureId","BaseGesture","constructor","gestureId","handlerTag","isWorklet","handlers","addDependency","key","gesture","value","config","Array","concat","withRef","ref","callback","__workletHash","undefined","onBegin","onStart","onEnd","onFinalize","onTouchesDown","needsPointerData","onTouchesMove","onTouchesUp","onTouchesCancelled","enabled","shouldCancelWhenOutside","hitSlop","activeCursor","mouseButton","runOnJS","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","blocksExternalGesture","withTestId","id","testId","cancelsTouchesInView","initialize","current","toGestureArray","prepare","shouldUseReanimated","includes","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":";;;;;;;AAWA;;AAQA;;;;AAgEO,MAAMA,aAAa,GAAG;AAC3BC,EAAAA,SAAS,EAAE,CADgB;AAE3BC,EAAAA,KAAK,EAAE,CAFoB;AAG3BC,EAAAA,KAAK,EAAE,CAHoB;AAI3BC,EAAAA,MAAM,EAAE,CAJmB;AAK3BC,EAAAA,MAAM,EAAE,CALmB;AAM3BC,EAAAA,GAAG,EAAE,CANsB;AAO3BC,EAAAA,QAAQ,EAAE,CAPiB;AAQ3BC,EAAAA,YAAY,EAAE,CARa;AAS3BC,EAAAA,YAAY,EAAE,CATa;AAU3BC,EAAAA,UAAU,EAAE,CAVe;AAW3BC,EAAAA,iBAAiB,EAAE;AAXQ,CAAtB,C,CAcP;AACA;;;;AAGO,MAAeC,OAAf,CAAuB;;;AAoB9B,IAAIC,aAAa,GAAG,CAApB;;AACO,MAAeC,WAAf,SAEGF,OAFH,CAEW;AAWhBG,EAAAA,WAAW,GAAG;AACZ,YADY,CAGZ;AACA;AACA;AACA;AACA;;AAPY,uCAVM,CAAC,CAUP;;AAAA,wCATM,CAAC,CASP;;AAAA,yCARO,EAQP;;AAAA,oCAPqB,EAOrB;;AAAA,sCANqC;AACjDC,MAAAA,SAAS,EAAE,CAAC,CADqC;AAEjDC,MAAAA,UAAU,EAAE,CAAC,CAFoC;AAGjDC,MAAAA,SAAS,EAAE;AAHsC,KAMrC;;AAQZ,SAAKF,SAAL,GAAiBH,aAAa,EAA9B;AACA,SAAKM,QAAL,CAAcH,SAAd,GAA0B,KAAKA,SAA/B;AACD;;AA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;AACA,WAAO,IAAP;AACD;;AAEDmC,EAAAA,gBAAgB,CAACA,gBAAD,EAA4B;AAC1C,SAAKxC,MAAL,CAAYwC,gBAAZ,GAA+BA,gBAA/B;AACA,WAAO,IAAP;AACD;;AApBkC","sourcesContent":["import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler';\nimport { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';\nimport {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n ActiveCursor,\n MouseButton,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../handlersRegistry';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport { LongPressGestureHandlerEventPayload } from '../LongPressGestureHandler';\nimport { PanGestureHandlerEventPayload } from '../PanGestureHandler';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { TapGestureHandlerEventPayload } from '../TapGestureHandler';\nimport { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';\nimport { isRemoteDebuggingEnabled } from '../../utils';\n\nexport type GestureType =\n | BaseGesture<Record<string, unknown>>\n | BaseGesture<Record<string, never>>\n | BaseGesture<TapGestureHandlerEventPayload>\n | BaseGesture<PanGestureHandlerEventPayload>\n | BaseGesture<LongPressGestureHandlerEventPayload>\n | BaseGesture<RotationGestureHandlerEventPayload>\n | BaseGesture<PinchGestureHandlerEventPayload>\n | BaseGesture<FlingGestureHandlerEventPayload>\n | BaseGesture<ForceTouchGestureHandlerEventPayload>\n | BaseGesture<NativeViewGestureHandlerPayload>;\n\nexport type GestureRef =\n | number\n | GestureType\n | React.RefObject<GestureType | undefined>\n | React.RefObject<React.ComponentType | undefined>; // allow adding a ref to a gesture handler\nexport interface BaseGestureConfig\n extends CommonGestureConfig,\n Record<string, unknown> {\n ref?: React.MutableRefObject<GestureType | undefined>;\n requireToFail?: GestureRef[];\n simultaneousWith?: GestureRef[];\n blocksHandlers?: GestureRef[];\n needsPointerData?: boolean;\n manualActivation?: boolean;\n runOnJS?: boolean;\n testId?: string;\n cancelsTouchesInView?: boolean;\n}\n\ntype TouchEventHandlerType = (\n event: GestureTouchEvent,\n stateManager: GestureStateManagerType\n) => void;\n\nexport type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {\n gestureId: number;\n handlerTag: number;\n onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onEnd?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onFinalize?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;\n onChange?: (event: any) => void;\n onTouchesDown?: TouchEventHandlerType;\n onTouchesMove?: TouchEventHandlerType;\n onTouchesUp?: TouchEventHandlerType;\n onTouchesCancelled?: TouchEventHandlerType;\n changeEventCalculator?: (\n current: GestureUpdateEvent<Record<string, unknown>>,\n previous?: GestureUpdateEvent<Record<string, unknown>>\n ) => GestureUpdateEvent<Record<string, unknown>>;\n isWorklet: boolean[];\n};\n\nexport const CALLBACK_TYPE = {\n UNDEFINED: 0,\n BEGAN: 1,\n START: 2,\n UPDATE: 3,\n CHANGE: 4,\n END: 5,\n FINALIZE: 6,\n TOUCHES_DOWN: 7,\n TOUCHES_MOVE: 8,\n TOUCHES_UP: 9,\n TOUCHES_CANCELLED: 10,\n} as const;\n\n// Allow using CALLBACK_TYPE as object and type\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];\n\nexport abstract class Gesture {\n /**\n * Return array of gestures, providing the same interface for creating and updating\n * handlers, no matter which object was used to create gesture instance.\n */\n abstract toGestureArray(): GestureType[];\n\n /**\n * Assign handlerTag to the gesture instance and set ref.current (if a ref is set)\n */\n abstract initialize(): void;\n\n /**\n * Make sure that values of properties defining relations are arrays. Do any necessary\n * preprocessing required to configure relations between handlers. Called just before\n * updating the handler on the native side.\n */\n abstract prepare(): void;\n}\n\nlet nextGestureId = 0;\nexport abstract class BaseGesture<\n EventPayloadT extends Record<string, unknown>\n> extends Gesture {\n private gestureId = -1;\n public handlerTag = -1;\n public handlerName = '';\n public config: BaseGestureConfig = {};\n public handlers: HandlerCallbacks<EventPayloadT> = {\n gestureId: -1,\n handlerTag: -1,\n isWorklet: [],\n };\n\n constructor() {\n super();\n\n // Used to check whether the gesture config has been updated when wrapping it\n // with `useMemo`. Since every config will have a unique id, when the dependencies\n // don't change, the config won't be recreated and the id will stay the same.\n // If the id is different, it means that the config has changed and the gesture\n // needs to be updated.\n this.gestureId = nextGestureId++;\n this.handlers.gestureId = this.gestureId;\n }\n\n private addDependency(\n key: 'simultaneousWith' | 'requireToFail' | 'blocksHandlers',\n gesture: Exclude<GestureRef, number>\n ) {\n const value = this.config[key];\n this.config[key] = value\n ? Array<GestureRef>().concat(value, gesture)\n : [gesture];\n }\n\n withRef(ref: React.MutableRefObject<GestureType | undefined>) {\n this.config.ref = ref;\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected isWorklet(callback: Function) {\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n return callback.__workletHash !== undefined;\n }\n\n onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onBegin = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);\n return this;\n }\n\n onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onStart = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);\n return this;\n }\n\n onEnd(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onEnd = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);\n return this;\n }\n\n onFinalize(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onFinalize = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);\n return this;\n }\n\n onTouchesDown(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesDown = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] =\n this.isWorklet(callback);\n\n return this;\n }\n\n onTouchesMove(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesMove = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] =\n this.isWorklet(callback);\n\n return this;\n }\n\n onTouchesUp(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesUp = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] =\n this.isWorklet(callback);\n\n return this;\n }\n\n onTouchesCancelled(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesCancelled = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] =\n this.isWorklet(callback);\n\n return this;\n }\n\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n activeCursor(activeCursor: ActiveCursor) {\n this.config.activeCursor = activeCursor;\n return this;\n }\n\n mouseButton(mouseButton: MouseButton) {\n this.config.mouseButton = mouseButton;\n return this;\n }\n\n runOnJS(runOnJS: boolean) {\n this.config.runOnJS = runOnJS;\n return this;\n }\n\n simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('simultaneousWith', gesture);\n }\n return this;\n }\n\n requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('requireToFail', gesture);\n }\n return this;\n }\n\n blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('blocksHandlers', gesture);\n }\n return this;\n }\n\n withTestId(id: string) {\n this.config.testId = id;\n return this;\n }\n\n cancelsTouchesInView(value: boolean) {\n this.config.cancelsTouchesInView = value;\n return this;\n }\n\n initialize() {\n this.handlerTag = getNextHandlerTag();\n\n this.handlers = { ...this.handlers, handlerTag: this.handlerTag };\n\n if (this.config.ref) {\n this.config.ref.current = this as GestureType;\n }\n }\n\n toGestureArray(): GestureType[] {\n return [this as GestureType];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prepare() {}\n\n get shouldUseReanimated(): boolean {\n // use Reanimated when runOnJS isn't set explicitly,\n // and all defined callbacks are worklets,\n // and remote debugging is disabled\n return (\n this.config.runOnJS !== true &&\n !this.handlers.isWorklet.includes(false) &&\n !isRemoteDebuggingEnabled()\n );\n }\n}\n\nexport abstract class ContinousBaseGesture<\n EventPayloadT extends Record<string, unknown>,\n EventChangePayloadT extends Record<string, unknown>\n> extends BaseGesture<EventPayloadT> {\n onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {\n this.handlers.onUpdate = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>\n ) => void\n ) {\n this.handlers.onChange = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);\n return this;\n }\n\n manualActivation(manualActivation: boolean) {\n this.config.manualActivation = manualActivation;\n return this;\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["gesture.ts"],"names":["CALLBACK_TYPE","UNDEFINED","BEGAN","START","UPDATE","CHANGE","END","FINALIZE","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED","Gesture","nextGestureId","BaseGesture","constructor","gestureId","handlerTag","isWorklet","handlers","addDependency","key","gesture","value","config","Array","concat","withRef","ref","callback","__workletHash","undefined","onBegin","onStart","onEnd","onFinalize","onTouchesDown","needsPointerData","onTouchesMove","onTouchesUp","onTouchesCancelled","enabled","shouldCancelWhenOutside","hitSlop","activeCursor","mouseButton","runOnJS","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","blocksExternalGesture","withTestId","id","testId","cancelsTouchesInView","initialize","current","toGestureArray","prepare","shouldUseReanimated","includes","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":";;;;;;;AAWA;;AAQA;;;;AAgEO,MAAMA,aAAa,GAAG;AAC3BC,EAAAA,SAAS,EAAE,CADgB;AAE3BC,EAAAA,KAAK,EAAE,CAFoB;AAG3BC,EAAAA,KAAK,EAAE,CAHoB;AAI3BC,EAAAA,MAAM,EAAE,CAJmB;AAK3BC,EAAAA,MAAM,EAAE,CALmB;AAM3BC,EAAAA,GAAG,EAAE,CANsB;AAO3BC,EAAAA,QAAQ,EAAE,CAPiB;AAQ3BC,EAAAA,YAAY,EAAE,CARa;AAS3BC,EAAAA,YAAY,EAAE,CATa;AAU3BC,EAAAA,UAAU,EAAE,CAVe;AAW3BC,EAAAA,iBAAiB,EAAE;AAXQ,CAAtB,C,CAcP;AACA;;;;AAGO,MAAeC,OAAf,CAAuB;;;AAoB9B,IAAIC,aAAa,GAAG,CAApB;;AACO,MAAeC,WAAf,SAEGF,OAFH,CAEW;AAWhBG,EAAAA,WAAW,GAAG;AACZ,YADY,CAGZ;AACA;AACA;AACA;AACA;;AAPY,uCAVM,CAAC,CAUP;;AAAA,wCATM,CAAC,CASP;;AAAA,yCARO,EAQP;;AAAA,oCAPqB,EAOrB;;AAAA,sCANqC;AACjDC,MAAAA,SAAS,EAAE,CAA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,GAAG,CAAE;;AAEW,MAAnBC,mBAAmB,GAAY;AACjC;AACA;AACA;AACA,WACE,KAAKnC,MAAL,CAAYsB,OAAZ,KAAwB,IAAxB,IACA,CAAC,KAAK3B,QAAL,CAAcD,SAAd,CAAwB0C,QAAxB,CAAiC,KAAjC,CADD,IAEA,CAAC,sCAHH;AAKD;;AA9Se;;;;AAiTX,MAAeC,oBAAf,SAGG/C,WAHH,CAG8B;AACnC;AACF;AACA;AACA;AACEgD,EAAAA,QAAQ,CAACjC,QAAD,EAA+D;AACrE,SAAKV,QAAL,CAAc2C,QAAd,GAAyBjC,QAAzB;AACA,SAAKV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACI,MAAtC,IAAgD,KAAKc,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEkC,EAAAA,QAAQ,CACNlC,QADM,EAIN;AACA,SAAKV,QAAL,CAAc4C,QAAd,GAAyBlC,QAAzB;AACA,SAAKV,QAAL,CAAcD,SAAd,CAAwBlB,aAAa,CAACK,MAAtC,IAAgD,KAAKa,SAAL,CAAeW,QAAf,CAAhD;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEmC,EAAAA,gBAAgB,CAACA,gBAAD,EAA4B;AAC1C,SAAKxC,MAAL,CAAYwC,gBAAZ,GAA+BA,gBAA/B;AACA,WAAO,IAAP;AACD;;AAlCkC","sourcesContent":["import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler';\nimport { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';\nimport {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n ActiveCursor,\n MouseButton,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../handlersRegistry';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport { LongPressGestureHandlerEventPayload } from '../LongPressGestureHandler';\nimport { PanGestureHandlerEventPayload } from '../PanGestureHandler';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { TapGestureHandlerEventPayload } from '../TapGestureHandler';\nimport { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';\nimport { isRemoteDebuggingEnabled } from '../../utils';\n\nexport type GestureType =\n | BaseGesture<Record<string, unknown>>\n | BaseGesture<Record<string, never>>\n | BaseGesture<TapGestureHandlerEventPayload>\n | BaseGesture<PanGestureHandlerEventPayload>\n | BaseGesture<LongPressGestureHandlerEventPayload>\n | BaseGesture<RotationGestureHandlerEventPayload>\n | BaseGesture<PinchGestureHandlerEventPayload>\n | BaseGesture<FlingGestureHandlerEventPayload>\n | BaseGesture<ForceTouchGestureHandlerEventPayload>\n | BaseGesture<NativeViewGestureHandlerPayload>;\n\nexport type GestureRef =\n | number\n | GestureType\n | React.RefObject<GestureType | undefined>\n | React.RefObject<React.ComponentType | undefined>; // allow adding a ref to a gesture handler\nexport interface BaseGestureConfig\n extends CommonGestureConfig,\n Record<string, unknown> {\n ref?: React.MutableRefObject<GestureType | undefined>;\n requireToFail?: GestureRef[];\n simultaneousWith?: GestureRef[];\n blocksHandlers?: GestureRef[];\n needsPointerData?: boolean;\n manualActivation?: boolean;\n runOnJS?: boolean;\n testId?: string;\n cancelsTouchesInView?: boolean;\n}\n\ntype TouchEventHandlerType = (\n event: GestureTouchEvent,\n stateManager: GestureStateManagerType\n) => void;\n\nexport type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {\n gestureId: number;\n handlerTag: number;\n onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onEnd?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onFinalize?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;\n onChange?: (event: any) => void;\n onTouchesDown?: TouchEventHandlerType;\n onTouchesMove?: TouchEventHandlerType;\n onTouchesUp?: TouchEventHandlerType;\n onTouchesCancelled?: TouchEventHandlerType;\n changeEventCalculator?: (\n current: GestureUpdateEvent<Record<string, unknown>>,\n previous?: GestureUpdateEvent<Record<string, unknown>>\n ) => GestureUpdateEvent<Record<string, unknown>>;\n isWorklet: boolean[];\n};\n\nexport const CALLBACK_TYPE = {\n UNDEFINED: 0,\n BEGAN: 1,\n START: 2,\n UPDATE: 3,\n CHANGE: 4,\n END: 5,\n FINALIZE: 6,\n TOUCHES_DOWN: 7,\n TOUCHES_MOVE: 8,\n TOUCHES_UP: 9,\n TOUCHES_CANCELLED: 10,\n} as const;\n\n// Allow using CALLBACK_TYPE as object and type\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];\n\nexport abstract class Gesture {\n /**\n * Return array of gestures, providing the same interface for creating and updating\n * handlers, no matter which object was used to create gesture instance.\n */\n abstract toGestureArray(): GestureType[];\n\n /**\n * Assign handlerTag to the gesture instance and set ref.current (if a ref is set)\n */\n abstract initialize(): void;\n\n /**\n * Make sure that values of properties defining relations are arrays. Do any necessary\n * preprocessing required to configure relations between handlers. Called just before\n * updating the handler on the native side.\n */\n abstract prepare(): void;\n}\n\nlet nextGestureId = 0;\nexport abstract class BaseGesture<\n EventPayloadT extends Record<string, unknown>\n> extends Gesture {\n private gestureId = -1;\n public handlerTag = -1;\n public handlerName = '';\n public config: BaseGestureConfig = {};\n public handlers: HandlerCallbacks<EventPayloadT> = {\n gestureId: -1,\n handlerTag: -1,\n isWorklet: [],\n };\n\n constructor() {\n super();\n\n // Used to check whether the gesture config has been updated when wrapping it\n // with `useMemo`. Since every config will have a unique id, when the dependencies\n // don't change, the config won't be recreated and the id will stay the same.\n // If the id is different, it means that the config has changed and the gesture\n // needs to be updated.\n this.gestureId = nextGestureId++;\n this.handlers.gestureId = this.gestureId;\n }\n\n private addDependency(\n key: 'simultaneousWith' | 'requireToFail' | 'blocksHandlers',\n gesture: Exclude<GestureRef, number>\n ) {\n const value = this.config[key];\n this.config[key] = value\n ? Array<GestureRef>().concat(value, gesture)\n : [gesture];\n }\n\n /**\n * Sets a `ref` to the gesture object, allowing for interoperability with the old API.\n * @param ref\n */\n withRef(ref: React.MutableRefObject<GestureType | undefined>) {\n this.config.ref = ref;\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected isWorklet(callback: Function) {\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n return callback.__workletHash !== undefined;\n }\n\n /**\n * Set the callback that is being called when given gesture handler starts receiving touches.\n * At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.\n * @param callback\n */\n onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onBegin = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);\n return this;\n }\n\n /**\n * Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.\n * @param callback\n */\n onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onStart = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);\n return this;\n }\n\n /**\n * Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.\n * It will be called only if the handler was previously in the `ACTIVE` state.\n * @param callback\n */\n onEnd(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onEnd = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);\n return this;\n }\n\n /**\n * Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.\n * @param callback\n */\n onFinalize(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onFinalize = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);\n return this;\n }\n\n /**\n * Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.\n * @param callback\n */\n onTouchesDown(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesDown = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] =\n this.isWorklet(callback);\n\n return this;\n }\n\n /**\n * Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.\n * @param callback\n */\n onTouchesMove(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesMove = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] =\n this.isWorklet(callback);\n\n return this;\n }\n\n /**\n * Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.\n * @param callback\n */\n onTouchesUp(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesUp = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] =\n this.isWorklet(callback);\n\n return this;\n }\n\n /**\n * Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.\n * @param callback\n */\n onTouchesCancelled(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesCancelled = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] =\n this.isWorklet(callback);\n\n return this;\n }\n\n /**\n * Indicates whether the given handler should be analyzing stream of touch events or not.\n * @param enabled\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean\n */\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n /**\n * When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.\n * @param value\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean\n */\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n /**\n * This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.\n * When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.\n * @param hitSlop\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings\n */\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n /**\n * #### Web only\n * This parameter allows to specify which `cursor` should be used when gesture activates.\n * Supports all CSS cursor values (e.g. `\"grab\"`, `\"zoom-in\"`). Default value is set to `\"auto\"`.\n * @param activeCursor\n */\n activeCursor(activeCursor: ActiveCursor) {\n this.config.activeCursor = activeCursor;\n return this;\n }\n\n /**\n * #### Web & Android only\n * Allows users to choose which mouse button should handler respond to.\n * Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.\n * Default value is set to `MouseButton.LEFT`.\n * @param mouseButton\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only\n */\n mouseButton(mouseButton: MouseButton) {\n this.config.mouseButton = mouseButton;\n return this;\n }\n\n /**\n * When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.\n * This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.\n * Defaults to `false`.\n * @param runOnJS\n */\n runOnJS(runOnJS: boolean) {\n this.config.runOnJS = runOnJS;\n return this;\n }\n\n /**\n * Allows gestures across different components to be recognized simultaneously.\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture\n */\n simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('simultaneousWith', gesture);\n }\n return this;\n }\n\n /**\n * Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail\n */\n requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('requireToFail', gesture);\n }\n return this;\n }\n\n /**\n * Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.\n * @param gestures\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture\n */\n blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('blocksHandlers', gesture);\n }\n return this;\n }\n\n /**\n * Sets a `testID` property for gesture object, allowing for querying for it in tests.\n * @param id\n */\n withTestId(id: string) {\n this.config.testId = id;\n return this;\n }\n\n /**\n * #### iOS only\n * When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.\n * Default value is `true`.\n * @param value\n */\n cancelsTouchesInView(value: boolean) {\n this.config.cancelsTouchesInView = value;\n return this;\n }\n\n initialize() {\n this.handlerTag = getNextHandlerTag();\n\n this.handlers = { ...this.handlers, handlerTag: this.handlerTag };\n\n if (this.config.ref) {\n this.config.ref.current = this as GestureType;\n }\n }\n\n toGestureArray(): GestureType[] {\n return [this as GestureType];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prepare() {}\n\n get shouldUseReanimated(): boolean {\n // use Reanimated when runOnJS isn't set explicitly,\n // and all defined callbacks are worklets,\n // and remote debugging is disabled\n return (\n this.config.runOnJS !== true &&\n !this.handlers.isWorklet.includes(false) &&\n !isRemoteDebuggingEnabled()\n );\n }\n}\n\nexport abstract class ContinousBaseGesture<\n EventPayloadT extends Record<string, unknown>,\n EventChangePayloadT extends Record<string, unknown>\n> extends BaseGesture<EventPayloadT> {\n /**\n * Set the callback that is being called every time the gesture receives an update while it's active.\n * @param callback\n */\n onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {\n this.handlers.onUpdate = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);\n return this;\n }\n\n /**\n * Set the callback that is being called every time the gesture receives an update while it's active.\n * This callback will receive information about change in value in relation to the last received event.\n * @param callback\n */\n onChange(\n callback: (\n event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>\n ) => void\n ) {\n this.handlers.onChange = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);\n return this;\n }\n\n /**\n * When `true` the handler will not activate by itself even if its activation criteria are met.\n * Instead you can manipulate its state using state manager.\n * @param manualActivation\n */\n manualActivation(manualActivation: boolean) {\n this.config.manualActivation = manualActivation;\n return this;\n }\n}\n"]}
|
@@ -27,34 +27,97 @@ var _manualGesture = require("./manualGesture");
|
|
27
27
|
|
28
28
|
var _hoverGesture = require("./hoverGesture");
|
29
29
|
|
30
|
+
/**
|
31
|
+
* `Gesture` is the object that allows you to create and compose gestures.
|
32
|
+
*
|
33
|
+
* ### Remarks
|
34
|
+
* - Consider wrapping your gesture configurations with `useMemo`, as it will reduce the amount of work Gesture Handler has to do under the hood when updating gestures.
|
35
|
+
*
|
36
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture
|
37
|
+
*/
|
30
38
|
const GestureObjects = {
|
39
|
+
/**
|
40
|
+
* A discrete gesture that recognizes one or many taps.
|
41
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
|
42
|
+
*/
|
31
43
|
Tap: () => {
|
32
44
|
return new _tapGesture.TapGesture();
|
33
45
|
},
|
46
|
+
|
47
|
+
/**
|
48
|
+
* A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
|
49
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
|
50
|
+
*/
|
34
51
|
Pan: () => {
|
35
52
|
return new _panGesture.PanGesture();
|
36
53
|
},
|
54
|
+
|
55
|
+
/**
|
56
|
+
* A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
|
57
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
|
58
|
+
*/
|
37
59
|
Pinch: () => {
|
38
60
|
return new _pinchGesture.PinchGesture();
|
39
61
|
},
|
62
|
+
|
63
|
+
/**
|
64
|
+
* A continuous gesture that can recognize rotation and track its movement.
|
65
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
|
66
|
+
*/
|
40
67
|
Rotation: () => {
|
41
68
|
return new _rotationGesture.RotationGesture();
|
42
69
|
},
|
70
|
+
|
71
|
+
/**
|
72
|
+
* A discrete gesture that activates when the movement is sufficiently fast.
|
73
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
|
74
|
+
*/
|
43
75
|
Fling: () => {
|
44
76
|
return new _flingGesture.FlingGesture();
|
45
77
|
},
|
78
|
+
|
79
|
+
/**
|
80
|
+
* A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
|
81
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
|
82
|
+
*/
|
46
83
|
LongPress: () => {
|
47
84
|
return new _longPressGesture.LongPressGesture();
|
48
85
|
},
|
86
|
+
|
87
|
+
/**
|
88
|
+
* #### iOS only
|
89
|
+
* A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
|
90
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture
|
91
|
+
*/
|
49
92
|
ForceTouch: () => {
|
50
93
|
return new _forceTouchGesture.ForceTouchGesture();
|
51
94
|
},
|
95
|
+
|
96
|
+
/**
|
97
|
+
* A gesture that allows other touch handling components to participate in RNGH's gesture system.
|
98
|
+
* When used, the other component should be the direct child of a `GestureDetector`.
|
99
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
|
100
|
+
*/
|
52
101
|
Native: () => {
|
53
102
|
return new _nativeGesture.NativeGesture();
|
54
103
|
},
|
104
|
+
|
105
|
+
/**
|
106
|
+
* A plain gesture that has no specific activation criteria nor event data set.
|
107
|
+
* Its state has to be controlled manually using a state manager.
|
108
|
+
* It will not fail when all the pointers are lifted from the screen.
|
109
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/manual-gesture
|
110
|
+
*/
|
55
111
|
Manual: () => {
|
56
112
|
return new _manualGesture.ManualGesture();
|
57
113
|
},
|
114
|
+
|
115
|
+
/**
|
116
|
+
* A continuous gesture that can recognize hovering above the view it's attached to.
|
117
|
+
* The hover effect may be activated by moving a mouse or a stylus over the view.
|
118
|
+
*
|
119
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/hover-gesture
|
120
|
+
*/
|
58
121
|
Hover: () => {
|
59
122
|
return new _hoverGesture.HoverGesture();
|
60
123
|
},
|
@@ -62,6 +125,7 @@ const GestureObjects = {
|
|
62
125
|
/**
|
63
126
|
* Builds a composed gesture consisting of gestures provided as parameters.
|
64
127
|
* The first one that becomes active cancels the rest of gestures.
|
128
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
|
65
129
|
*/
|
66
130
|
Race: (...gestures) => {
|
67
131
|
return new _gestureComposition.ComposedGesture(...gestures);
|
@@ -69,6 +133,7 @@ const GestureObjects = {
|
|
69
133
|
|
70
134
|
/**
|
71
135
|
* Builds a composed gesture that allows all base gestures to run simultaneously.
|
136
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
|
72
137
|
*/
|
73
138
|
Simultaneous(...gestures) {
|
74
139
|
return new _gestureComposition.SimultaneousGesture(...gestures);
|
@@ -80,6 +145,7 @@ const GestureObjects = {
|
|
80
145
|
* than the second one, second one has higher priority than the third one, and so on.
|
81
146
|
* For example, to make a gesture that recognizes both single and double tap you need
|
82
147
|
* to call Exclusive(doubleTap, singleTap).
|
148
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#exclusive
|
83
149
|
*/
|
84
150
|
Exclusive(...gestures) {
|
85
151
|
return new _gestureComposition.ExclusiveGesture(...gestures);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gestureObjects.ts"],"names":["GestureObjects","Tap","TapGesture","Pan","PanGesture","Pinch","PinchGesture","Rotation","RotationGesture","Fling","FlingGesture","LongPress","LongPressGesture","ForceTouch","ForceTouchGesture","Native","NativeGesture","Manual","ManualGesture","Hover","HoverGesture","Race","gestures","ComposedGesture","Simultaneous","SimultaneousGesture","Exclusive","ExclusiveGesture"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
1
|
+
{"version":3,"sources":["gestureObjects.ts"],"names":["GestureObjects","Tap","TapGesture","Pan","PanGesture","Pinch","PinchGesture","Rotation","RotationGesture","Fling","FlingGesture","LongPress","LongPressGesture","ForceTouch","ForceTouchGesture","Native","NativeGesture","Manual","ManualGesture","Hover","HoverGesture","Race","gestures","ComposedGesture","Simultaneous","SimultaneousGesture","Exclusive","ExclusiveGesture"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAG;AAC5B;AACF;AACA;AACA;AACEC,EAAAA,GAAG,EAAE,MAAM;AACT,WAAO,IAAIC,sBAAJ,EAAP;AACD,GAP2B;;AAS5B;AACF;AACA;AACA;AACEC,EAAAA,GAAG,EAAE,MAAM;AACT,WAAO,IAAIC,sBAAJ,EAAP;AACD,GAf2B;;AAiB5B;AACF;AACA;AACA;AACEC,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L,QAAxB,CAAP;AACD;;AAlH2B,CAAvB","sourcesContent":["import { FlingGesture } from './flingGesture';\nimport { ForceTouchGesture } from './forceTouchGesture';\nimport { Gesture } from './gesture';\nimport {\n ComposedGesture,\n ExclusiveGesture,\n SimultaneousGesture,\n} from './gestureComposition';\nimport { LongPressGesture } from './longPressGesture';\nimport { PanGesture } from './panGesture';\nimport { PinchGesture } from './pinchGesture';\nimport { RotationGesture } from './rotationGesture';\nimport { TapGesture } from './tapGesture';\nimport { NativeGesture } from './nativeGesture';\nimport { ManualGesture } from './manualGesture';\nimport { HoverGesture } from './hoverGesture';\n\n/**\n * `Gesture` is the object that allows you to create and compose gestures.\n *\n * ### Remarks\n * - Consider wrapping your gesture configurations with `useMemo`, as it will reduce the amount of work Gesture Handler has to do under the hood when updating gestures.\n *\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture\n */\nexport const GestureObjects = {\n /**\n * A discrete gesture that recognizes one or many taps.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture\n */\n Tap: () => {\n return new TapGesture();\n },\n\n /**\n * A continuous gesture that can recognize a panning (dragging) gesture and track its movement.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture\n */\n Pan: () => {\n return new PanGesture();\n },\n\n /**\n * A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture\n */\n Pinch: () => {\n return new PinchGesture();\n },\n\n /**\n * A continuous gesture that can recognize rotation and track its movement.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture\n */\n Rotation: () => {\n return new RotationGesture();\n },\n\n /**\n * A discrete gesture that activates when the movement is sufficiently fast.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture\n */\n Fling: () => {\n return new FlingGesture();\n },\n\n /**\n * A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture\n */\n LongPress: () => {\n return new LongPressGesture();\n },\n\n /**\n * #### iOS only\n * A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture\n */\n ForceTouch: () => {\n return new ForceTouchGesture();\n },\n\n /**\n * A gesture that allows other touch handling components to participate in RNGH's gesture system.\n * When used, the other component should be the direct child of a `GestureDetector`.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture\n */\n Native: () => {\n return new NativeGesture();\n },\n\n /**\n * A plain gesture that has no specific activation criteria nor event data set.\n * Its state has to be controlled manually using a state manager.\n * It will not fail when all the pointers are lifted from the screen.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/manual-gesture\n */\n Manual: () => {\n return new ManualGesture();\n },\n\n /**\n * A continuous gesture that can recognize hovering above the view it's attached to.\n * The hover effect may be activated by moving a mouse or a stylus over the view.\n *\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/hover-gesture\n */\n Hover: () => {\n return new HoverGesture();\n },\n\n /**\n * Builds a composed gesture consisting of gestures provided as parameters.\n * The first one that becomes active cancels the rest of gestures.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race\n */\n Race: (...gestures: Gesture[]) => {\n return new ComposedGesture(...gestures);\n },\n\n /**\n * Builds a composed gesture that allows all base gestures to run simultaneously.\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous\n */\n Simultaneous(...gestures: Gesture[]) {\n return new SimultaneousGesture(...gestures);\n },\n\n /**\n * Builds a composed gesture where only one of the provided gestures can become active.\n * Priority is decided through the order of gestures: the first one has higher priority\n * than the second one, second one has higher priority than the third one, and so on.\n * For example, to make a gesture that recognizes both single and double tap you need\n * to call Exclusive(doubleTap, singleTap).\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#exclusive\n */\n Exclusive(...gestures: Gesture[]) {\n return new ExclusiveGesture(...gestures);\n },\n};\n"]}
|
@@ -16,7 +16,7 @@ const GestureStateManager = {
|
|
16
16
|
_NodeManager.default.getHandler(handlerTag).begin();
|
17
17
|
},
|
18
18
|
activate: () => {
|
19
|
-
_NodeManager.default.getHandler(handlerTag).activate();
|
19
|
+
_NodeManager.default.getHandler(handlerTag).activate(true);
|
20
20
|
},
|
21
21
|
fail: () => {
|
22
22
|
_NodeManager.default.getHandler(handlerTag).fail();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gestureStateManager.web.ts"],"names":["GestureStateManager","create","handlerTag","begin","NodeManager","getHandler","activate","fail","end"],"mappings":";;;;;;;AAAA;;;;AAGO,MAAMA,mBAAmB,GAAG;AACjCC,EAAAA,MAAM,CAACC,UAAD,EAA8C;AAClD,WAAO;AACLC,MAAAA,KAAK,EAAE,MAAM;AACXC,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCC,KAAnC;AACD,OAHI;AAKLG,MAAAA,QAAQ,EAAE,MAAM;AACdF,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCI,QAAnC;AACD,OAPI;AASLC,MAAAA,IAAI,EAAE,MAAM;AACVH,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCK,IAAnC;AACD,OAXI;AAaLC,MAAAA,GAAG,EAAE,MAAM;AACTJ,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCM,GAAnC;AACD;AAfI,KAAP;AAiBD;;AAnBgC,CAA5B","sourcesContent":["import NodeManager from '../../web/tools/NodeManager';\nimport { GestureStateManagerType } from './gestureStateManager';\n\nexport const GestureStateManager = {\n create(handlerTag: number): GestureStateManagerType {\n return {\n begin: () => {\n NodeManager.getHandler(handlerTag).begin();\n },\n\n activate: () => {\n NodeManager.getHandler(handlerTag).activate();\n },\n\n fail: () => {\n NodeManager.getHandler(handlerTag).fail();\n },\n\n end: () => {\n NodeManager.getHandler(handlerTag).end();\n },\n };\n },\n};\n"]}
|
1
|
+
{"version":3,"sources":["gestureStateManager.web.ts"],"names":["GestureStateManager","create","handlerTag","begin","NodeManager","getHandler","activate","fail","end"],"mappings":";;;;;;;AAAA;;;;AAGO,MAAMA,mBAAmB,GAAG;AACjCC,EAAAA,MAAM,CAACC,UAAD,EAA8C;AAClD,WAAO;AACLC,MAAAA,KAAK,EAAE,MAAM;AACXC,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCC,KAAnC;AACD,OAHI;AAKLG,MAAAA,QAAQ,EAAE,MAAM;AACdF,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCI,QAAnC,CAA4C,IAA5C;AACD,OAPI;AASLC,MAAAA,IAAI,EAAE,MAAM;AACVH,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCK,IAAnC;AACD,OAXI;AAaLC,MAAAA,GAAG,EAAE,MAAM;AACTJ,6BAAYC,UAAZ,CAAuBH,UAAvB,EAAmCM,GAAnC;AACD;AAfI,KAAP;AAiBD;;AAnBgC,CAA5B","sourcesContent":["import NodeManager from '../../web/tools/NodeManager';\nimport { GestureStateManagerType } from './gestureStateManager';\n\nexport const GestureStateManager = {\n create(handlerTag: number): GestureStateManagerType {\n return {\n begin: () => {\n NodeManager.getHandler(handlerTag).begin();\n },\n\n activate: () => {\n NodeManager.getHandler(handlerTag).activate(true);\n },\n\n fail: () => {\n NodeManager.getHandler(handlerTag).fail();\n },\n\n end: () => {\n NodeManager.getHandler(handlerTag).end();\n },\n };\n },\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["hoverGesture.ts"],"names":["HoverEffect","hoverGestureHandlerProps","changeEventCalculator","current","previous","changePayload","undefined","changeX","x","changeY","y","HoverGesture","ContinousBaseGesture","constructor","handlerName","effect","config","hoverEffect","onChange","callback","handlers"],"mappings":";;;;;;;AAAA;;;;IAeYA,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W;;AAUL,MAAMC,wBAAwB,GAAG,CAAC,aAAD,CAAjC;;;AAEP,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CAAR,GAAYJ,QAAQ,CAACI,CADhB;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,CAAR,GAAYN,QAAQ,CAACM;AAFhB,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAEM,MAAMM,YAAN,SAA2BC,6BAA3B,CAGL;AAGAC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,MAAM,CAACA,MAAD,EAAsB;AAC1B,SAAKC,MAAL,CAAYC,WAAZ,GAA0BF,MAA1B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAclB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMgB,QAAN,CAAeC,QAAf,CAAP;AACD;;AA5BD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type HoverGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type HoverGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nexport enum HoverEffect {\n NONE = 0,\n LIFT = 1,\n HIGHLIGHT = 2,\n}\n\nexport interface HoverGestureConfig {\n hoverEffect?: HoverEffect;\n}\n\nexport const hoverGestureHandlerProps = ['hoverEffect'] as const;\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: HoverGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.x,\n changeY: current.y,\n };\n } else {\n changePayload = {\n changeX: current.x - previous.x,\n changeY: current.y - previous.y,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class HoverGesture extends ContinousBaseGesture<\n HoverGestureHandlerEventPayload,\n HoverGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & HoverGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'HoverGestureHandler';\n }\n\n /**\n * Sets the visual hover effect.\n
|
1
|
+
{"version":3,"sources":["hoverGesture.ts"],"names":["HoverEffect","hoverGestureHandlerProps","changeEventCalculator","current","previous","changePayload","undefined","changeX","x","changeY","y","HoverGesture","ContinousBaseGesture","constructor","handlerName","effect","config","hoverEffect","onChange","callback","handlers"],"mappings":";;;;;;;AAAA;;;;IAeYA,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W;;AAUL,MAAMC,wBAAwB,GAAG,CAAC,aAAD,CAAjC;;;AAEP,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CAAR,GAAYJ,QAAQ,CAACI,CADhB;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,CAAR,GAAYN,QAAQ,CAACM;AAFhB,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAEM,MAAMM,YAAN,SAA2BC,6BAA3B,CAGL;AAGAC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,MAAM,CAACA,MAAD,EAAsB;AAC1B,SAAKC,MAAL,CAAYC,WAAZ,GAA0BF,MAA1B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAclB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMgB,QAAN,CAAeC,QAAf,CAAP;AACD;;AA5BD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type HoverGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type HoverGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nexport enum HoverEffect {\n NONE = 0,\n LIFT = 1,\n HIGHLIGHT = 2,\n}\n\nexport interface HoverGestureConfig {\n hoverEffect?: HoverEffect;\n}\n\nexport const hoverGestureHandlerProps = ['hoverEffect'] as const;\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: HoverGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.x,\n changeY: current.y,\n };\n } else {\n changePayload = {\n changeX: current.x - previous.x,\n changeY: current.y - previous.y,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class HoverGesture extends ContinousBaseGesture<\n HoverGestureHandlerEventPayload,\n HoverGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & HoverGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'HoverGestureHandler';\n }\n\n /**\n * #### iOS only\n * Sets the visual hover effect.\n */\n effect(effect: HoverEffect) {\n this.config.hoverEffect = effect;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type HoverGestureType = InstanceType<typeof HoverGesture>;\n"]}
|