react-native-gesture-handler 2.3.2 → 2.4.2

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 (166) hide show
  1. package/RNGestureHandler.podspec +2 -1
  2. package/android/build.gradle +38 -6
  3. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +14 -2
  4. package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +10 -0
  5. package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +17 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +3 -41
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +6 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +10 -54
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -0
  10. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +6 -0
  11. package/ios/RNGHTouchEventType.h +9 -0
  12. package/ios/RNGestureHandler.h +2 -2
  13. package/ios/RNGestureHandler.m +21 -8
  14. package/ios/RNGestureHandlerButton.h +1 -0
  15. package/ios/RNGestureHandlerButton.m +9 -1
  16. package/ios/RNGestureHandlerButtonComponentView.mm +14 -1
  17. package/ios/RNGestureHandlerButtonManager.m +4 -1
  18. package/ios/RNGestureHandlerEvents.h +2 -2
  19. package/ios/RNGestureHandlerEvents.m +2 -2
  20. package/ios/RNGestureHandlerManager.h +2 -0
  21. package/ios/RNGestureHandlerManager.mm +30 -20
  22. package/ios/RNGestureHandlerModule.mm +18 -0
  23. package/ios/RNGestureHandlerPointerTracker.h +2 -2
  24. package/ios/RNGestureHandlerPointerTracker.m +9 -6
  25. package/ios/RNGestureHandlerRegistry.h +1 -0
  26. package/ios/RNGestureHandlerRegistry.m +10 -0
  27. package/lib/commonjs/GestureHandlerRootView.android.js +7 -1
  28. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  29. package/lib/commonjs/GestureHandlerRootView.js +6 -0
  30. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  31. package/lib/commonjs/GestureHandlerRootView.web.js +19 -0
  32. package/lib/commonjs/GestureHandlerRootView.web.js.map +1 -0
  33. package/lib/commonjs/RNGestureHandlerModule.js +5 -0
  34. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  35. package/lib/commonjs/RNGestureHandlerModule.web.js +4 -1
  36. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  37. package/lib/commonjs/{EventType.js → TouchEventType.js} +4 -4
  38. package/lib/commonjs/TouchEventType.js.map +1 -0
  39. package/lib/commonjs/components/DrawerLayout.js +38 -11
  40. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  41. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  42. package/lib/commonjs/components/GestureHandlerButton.js +1 -1
  43. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  44. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -0
  45. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  46. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +4 -6
  47. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  48. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +4 -6
  49. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  50. package/lib/commonjs/getShadowNodeFromRef.js +12 -9
  51. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  52. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +2 -1
  53. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
  54. package/lib/commonjs/handlers/createHandler.js +25 -20
  55. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  56. package/lib/commonjs/handlers/gestureHandlerCommon.js +18 -1
  57. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  58. package/lib/commonjs/handlers/gestures/GestureDetector.js +120 -80
  59. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  60. package/lib/commonjs/handlers/gestures/eventReceiver.js +6 -5
  61. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  62. package/lib/commonjs/handlers/gestures/gesture.js +24 -4
  63. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  64. package/lib/commonjs/init.js +10 -1
  65. package/lib/commonjs/init.js.map +1 -1
  66. package/lib/commonjs/mocks.js +2 -0
  67. package/lib/commonjs/mocks.js.map +1 -1
  68. package/lib/commonjs/utils.js +23 -1
  69. package/lib/commonjs/utils.js.map +1 -1
  70. package/lib/commonjs/web/GestureHandler.js +4 -1
  71. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  72. package/lib/commonjs/web/utils.js.map +1 -1
  73. package/lib/module/GestureHandlerRootView.android.js +7 -2
  74. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  75. package/lib/module/GestureHandlerRootView.js +5 -0
  76. package/lib/module/GestureHandlerRootView.js.map +1 -1
  77. package/lib/module/GestureHandlerRootView.web.js +6 -0
  78. package/lib/module/GestureHandlerRootView.web.js.map +1 -0
  79. package/lib/module/RNGestureHandlerModule.js +5 -0
  80. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  81. package/lib/module/RNGestureHandlerModule.web.js +4 -1
  82. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  83. package/lib/module/{EventType.js → TouchEventType.js} +2 -2
  84. package/lib/module/TouchEventType.js.map +1 -0
  85. package/lib/module/components/DrawerLayout.js +38 -11
  86. package/lib/module/components/DrawerLayout.js.map +1 -1
  87. package/lib/module/components/GestureButtons.js.map +1 -1
  88. package/lib/module/components/GestureHandlerButton.js +2 -2
  89. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  90. package/lib/module/components/touchables/GenericTouchable.js +2 -0
  91. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  92. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +5 -7
  93. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  94. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +5 -8
  95. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  96. package/lib/module/getShadowNodeFromRef.js +11 -8
  97. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  98. package/lib/module/handlers/ForceTouchGestureHandler.js +1 -1
  99. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
  100. package/lib/module/handlers/createHandler.js +25 -22
  101. package/lib/module/handlers/createHandler.js.map +1 -1
  102. package/lib/module/handlers/gestureHandlerCommon.js +11 -1
  103. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  104. package/lib/module/handlers/gestures/GestureDetector.js +120 -81
  105. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  106. package/lib/module/handlers/gestures/eventReceiver.js +6 -7
  107. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  108. package/lib/module/handlers/gestures/gesture.js +23 -4
  109. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  110. package/lib/module/init.js +6 -1
  111. package/lib/module/init.js.map +1 -1
  112. package/lib/module/mocks.js +2 -0
  113. package/lib/module/mocks.js.map +1 -1
  114. package/lib/module/utils.js +17 -1
  115. package/lib/module/utils.js.map +1 -1
  116. package/lib/module/web/GestureHandler.js +4 -1
  117. package/lib/module/web/GestureHandler.js.map +1 -1
  118. package/lib/module/web/utils.js.map +1 -1
  119. package/lib/typescript/GestureHandlerRootView.web.d.ts +5 -0
  120. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  121. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  122. package/lib/typescript/{EventType.d.ts → TouchEventType.d.ts} +2 -2
  123. package/lib/typescript/components/DrawerLayout.d.ts +3 -0
  124. package/lib/typescript/components/GestureButtons.d.ts +18 -6
  125. package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
  126. package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
  127. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
  128. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  129. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +6 -3
  130. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -4
  131. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  132. package/lib/typescript/handlers/gestures/gesture.d.ts +5 -0
  133. package/lib/typescript/init.d.ts +1 -0
  134. package/lib/typescript/mocks.d.ts +1 -0
  135. package/lib/typescript/utils.d.ts +2 -0
  136. package/lib/typescript/web/GestureHandler.d.ts +1 -1
  137. package/package.json +4 -2
  138. package/src/GestureHandlerRootView.android.tsx +8 -2
  139. package/src/GestureHandlerRootView.tsx +6 -0
  140. package/src/GestureHandlerRootView.web.tsx +12 -0
  141. package/src/RNGestureHandlerModule.ts +7 -0
  142. package/src/RNGestureHandlerModule.web.ts +2 -0
  143. package/src/{EventType.ts → TouchEventType.ts} +2 -2
  144. package/src/components/DrawerLayout.tsx +34 -10
  145. package/src/components/GestureButtons.tsx +21 -7
  146. package/src/components/GestureHandlerButton.tsx +2 -2
  147. package/src/components/touchables/GenericTouchable.tsx +2 -0
  148. package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
  149. package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
  150. package/src/getShadowNodeFromRef.ts +12 -9
  151. package/src/handlers/ForceTouchGestureHandler.ts +3 -2
  152. package/src/handlers/createHandler.ts +30 -26
  153. package/src/handlers/gestureHandlerCommon.ts +21 -2
  154. package/src/handlers/gestures/GestureDetector.tsx +164 -105
  155. package/src/handlers/gestures/eventReceiver.ts +6 -6
  156. package/src/handlers/gestures/gesture.ts +29 -2
  157. package/src/init.ts +8 -1
  158. package/src/mocks.ts +2 -0
  159. package/src/utils.ts +20 -0
  160. package/src/web/GestureHandler.ts +7 -1
  161. package/src/web/utils.ts +1 -1
  162. package/ios/RNTouchEventType.h +0 -9
  163. package/lib/commonjs/EventType.js.map +0 -1
  164. package/lib/module/EventType.js.map +0 -1
  165. package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
  166. package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
@@ -48,6 +48,7 @@
48
48
  RCTUIManager *_uiManager;
49
49
  NSHashTable<RNRootViewGestureRecognizer *> *_rootViewGestureRecognizers;
50
50
  RCTEventDispatcher *_eventDispatcher;
51
+ id _reanimatedModule;
51
52
  }
52
53
 
53
54
  - (instancetype)initWithUIManager:(RCTUIManager *)uiManager
@@ -58,6 +59,7 @@
58
59
  _eventDispatcher = eventDispatcher;
59
60
  _registry = [RNGestureHandlerRegistry new];
60
61
  _rootViewGestureRecognizers = [NSHashTable hashTableWithOptions:NSPointerFunctionsWeakMemory];
62
+ _reanimatedModule = nil;
61
63
  }
62
64
  return self;
63
65
  }
@@ -139,6 +141,11 @@
139
141
  [_registry dropHandlerWithTag:handlerTag];
140
142
  }
141
143
 
144
+ - (void)dropAllGestureHandlers
145
+ {
146
+ [_registry dropAllHandlers];
147
+ }
148
+
142
149
  - (void)handleSetJSResponder:(NSNumber *)viewTag blockNativeResponder:(NSNumber *)blockNativeResponder
143
150
  {
144
151
  if ([blockNativeResponder boolValue]) {
@@ -210,80 +217,83 @@
210
217
 
211
218
  #pragma mark Events
212
219
 
213
- - (void)sendStateChangeEvent:(RNGestureHandlerStateChange *)event withActionType:(RNGestureHandlerActionType)actionType
220
+ - (void)sendEvent:(RNGestureHandlerStateChange *)event withActionType:(RNGestureHandlerActionType)actionType
214
221
  {
215
222
  switch (actionType) {
216
223
  case RNGestureHandlerActionTypeReanimatedWorklet:
217
- [self sendStateChangeEventForReanimated:event];
224
+ [self sendEventForReanimated:event];
218
225
  break;
219
226
 
220
227
  case RNGestureHandlerActionTypeNativeAnimatedEvent:
221
228
  if ([event.eventName isEqualToString:@"onGestureHandlerEvent"]) {
222
- [self sendStateChangeEventForNativeAnimatedEvent:event];
229
+ [self sendEventForNativeAnimatedEvent:event];
223
230
  } else {
224
231
  // Although onGestureEvent prop is an Animated.event with useNativeDriver: true,
225
232
  // onHandlerStateChange prop is still a regular JS function.
226
233
  // Also, Animated.event is only supported with old API.
227
- [self sendStateChangeEventForJSFunctionOldAPI:event];
234
+ [self sendEventForJSFunctionOldAPI:event];
228
235
  }
229
236
  break;
230
237
 
231
238
  case RNGestureHandlerActionTypeJSFunctionOldAPI:
232
- [self sendStateChangeEventForJSFunctionOldAPI:event];
239
+ [self sendEventForJSFunctionOldAPI:event];
233
240
  break;
234
241
 
235
242
  case RNGestureHandlerActionTypeJSFunctionNewAPI:
236
- [self sendStateChangeEventForJSFunctionNewAPI:event];
243
+ [self sendEventForJSFunctionNewAPI:event];
237
244
  break;
238
245
  }
239
246
  }
240
247
 
241
- - (void)sendStateChangeEventForReanimated:(RNGestureHandlerStateChange *)event
248
+ - (void)sendEventForReanimated:(RNGestureHandlerStateChange *)event
242
249
  {
243
250
  // Delivers the event to Reanimated.
244
251
  #ifdef RN_FABRIC_ENABLED
245
- // TODO: send event directly to Reanimated
246
- // This is already supported in Reanimated with Fabric but let's wait until the official release.
247
- // [_reanimatedModule eventDispatcherWillDispatchEvent:event];
252
+ // Send event directly to Reanimated
253
+ if (_reanimatedModule == nil) {
254
+ _reanimatedModule = [_uiManager.bridge moduleForName:@"ReanimatedModule"];
255
+ }
256
+
257
+ [_reanimatedModule eventDispatcherWillDispatchEvent:event];
248
258
  #else
249
259
  // In the old architecture, Reanimated overwrites RCTEventDispatcher
250
260
  // with REAEventDispatcher and intercepts all direct events.
251
- [self sendStateChangeEventForDirectEvent:event];
261
+ [self sendEventForDirectEvent:event];
252
262
  #endif // RN_FABRIC_ENABLED
253
263
  }
254
264
 
255
- - (void)sendStateChangeEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
265
+ - (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
256
266
  {
257
267
  // Delivers the event to NativeAnimatedModule.
258
268
  // Currently, NativeAnimated[Turbo]Module is RCTEventDispatcherObserver so we can
259
269
  // simply send a direct event which is handled by the observer but ignored on JS side.
260
270
  // TODO: send event directly to NativeAnimated[Turbo]Module
261
- [self sendStateChangeEventForDirectEvent:event];
271
+ [self sendEventForDirectEvent:event];
262
272
  }
263
273
 
264
- - (void)sendStateChangeEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
274
+ - (void)sendEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
265
275
  {
266
276
  // Delivers the event to JS (old RNGH API).
267
277
  #ifdef RN_FABRIC_ENABLED
268
- [self sendStateChangeEventForDeviceEvent:event];
278
+ [self sendEventForDeviceEvent:event];
269
279
  #else
270
- [self sendStateChangeEventForDirectEvent:event];
280
+ [self sendEventForDirectEvent:event];
271
281
  #endif // RN_FABRIC_ENABLED
272
282
  }
273
283
 
274
- - (void)sendStateChangeEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
284
+ - (void)sendEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
275
285
  {
276
286
  // Delivers the event to JS (new RNGH API).
277
- [self sendStateChangeEventForDeviceEvent:event];
287
+ [self sendEventForDeviceEvent:event];
278
288
  }
279
289
 
280
- - (void)sendStateChangeEventForDirectEvent:(RNGestureHandlerStateChange *)event
290
+ - (void)sendEventForDirectEvent:(RNGestureHandlerStateChange *)event
281
291
  {
282
292
  // Delivers the event to JS as a direct event.
283
293
  [_eventDispatcher sendEvent:event];
284
294
  }
285
295
 
286
- - (void)sendStateChangeEventForDeviceEvent:(RNGestureHandlerStateChange *)event
296
+ - (void)sendEventForDeviceEvent:(RNGestureHandlerStateChange *)event
287
297
  {
288
298
  // Delivers the event to JS as a device event.
289
299
  NSMutableDictionary *body = [[event arguments] objectAtIndex:2];
@@ -60,6 +60,8 @@ RCT_EXPORT_MODULE()
60
60
 
61
61
  - (void)invalidate
62
62
  {
63
+ [_manager dropAllGestureHandlers];
64
+
63
65
  _manager = nil;
64
66
 
65
67
  #ifdef RN_FABRIC_ENABLED
@@ -173,6 +175,22 @@ RCT_EXPORT_METHOD(handleClearJSResponder)
173
175
  }];
174
176
  }
175
177
 
178
+ RCT_EXPORT_METHOD(flushOperations)
179
+ {
180
+ if (_operations.count == 0) {
181
+ return;
182
+ }
183
+
184
+ NSArray<GestureHandlerOperation> *operations = _operations;
185
+ _operations = [NSMutableArray new];
186
+
187
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
188
+ for (GestureHandlerOperation operation in operations) {
189
+ operation(self->_manager);
190
+ }
191
+ }];
192
+ }
193
+
176
194
  - (void)setGestureState:(int)state forHandler:(int)handlerTag
177
195
  {
178
196
  RNGestureHandler *handler = [_manager handlerWithTag:@(handlerTag)];
@@ -1,6 +1,6 @@
1
1
  #import <Foundation/Foundation.h>
2
2
 
3
- #import "RNTouchEventType.h"
3
+ #import "RNGHTouchEventType.h"
4
4
 
5
5
  #define MAX_POINTERS_COUNT 12
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  @interface RNGestureHandlerPointerTracker : NSObject
10
10
 
11
- @property (nonatomic) RNTouchEventType eventType;
11
+ @property (nonatomic) RNGHTouchEventType eventType;
12
12
  @property (nonatomic) NSArray<NSDictionary *> *changedPointersData;
13
13
  @property (nonatomic) NSArray<NSDictionary *> *allPointersData;
14
14
  @property (nonatomic) int trackedPointersCount;
@@ -103,7 +103,7 @@
103
103
  return;
104
104
  }
105
105
 
106
- _eventType = RNTouchEventTypePointerDown;
106
+ _eventType = RNGHTouchEventTypePointerDown;
107
107
 
108
108
  NSDictionary *data[touches.count];
109
109
 
@@ -129,7 +129,7 @@
129
129
  return;
130
130
  }
131
131
 
132
- _eventType = RNTouchEventTypePointerMove;
132
+ _eventType = RNGHTouchEventTypePointerMove;
133
133
 
134
134
  NSDictionary *data[touches.count];
135
135
 
@@ -153,7 +153,7 @@
153
153
  // extract all touches first to include the ones that were just lifted
154
154
  [self extractAllTouches];
155
155
 
156
- _eventType = RNTouchEventTypePointerUp;
156
+ _eventType = RNGHTouchEventTypePointerUp;
157
157
 
158
158
  NSDictionary *data[touches.count];
159
159
 
@@ -188,7 +188,7 @@
188
188
 
189
189
  if (_trackedPointersCount == 0) {
190
190
  // gesture has finished because all pointers were lifted, reset event type to send state change event
191
- _eventType = RNTouchEventTypeUndetermined;
191
+ _eventType = RNGHTouchEventTypeUndetermined;
192
192
  } else {
193
193
  // turns out that the gesture may be made to fail without calling touchesCancelled in that case there
194
194
  // are still tracked pointers but the recognizer state is already set to UIGestureRecognizerStateFailed
@@ -218,7 +218,7 @@
218
218
  }
219
219
  }
220
220
 
221
- _eventType = RNTouchEventTypeCancelled;
221
+ _eventType = RNGHTouchEventTypeCancelled;
222
222
  _changedPointersData = [[NSArray alloc] initWithObjects:data count:registeredTouches];
223
223
  [self sendEvent];
224
224
  _trackedPointersCount = 0;
@@ -227,7 +227,10 @@
227
227
 
228
228
  - (void)sendEvent
229
229
  {
230
- if (!_gestureHandler.needsPointerData) {
230
+ // it may happen that the gesture recognizer is reset after it's been unbound from the view,
231
+ // it that recognizer tried to send event, the app would crash because the target of the event
232
+ // would be nil.
233
+ if (!_gestureHandler.needsPointerData || _gestureHandler.recognizer.view.reactTag == nil) {
231
234
  return;
232
235
  }
233
236
 
@@ -14,5 +14,6 @@
14
14
  - (void)registerGestureHandler:(nonnull RNGestureHandler *)gestureHandler;
15
15
  - (void)attachHandlerWithTag:(nonnull NSNumber *)handlerTag toView:(nonnull UIView *)view withActionType:(RNGestureHandlerActionType)actionType;
16
16
  - (void)dropHandlerWithTag:(nonnull NSNumber *)handlerTag;
17
+ - (void)dropAllHandlers;
17
18
 
18
19
  @end
@@ -48,4 +48,14 @@
48
48
  [_handlers removeObjectForKey:handlerTag];
49
49
  }
50
50
 
51
+ - (void)dropAllHandlers
52
+ {
53
+ for (NSNumber* tag in _handlers) {
54
+ RNGestureHandler *handler = _handlers[tag];
55
+ [handler unbindFromView];
56
+ }
57
+
58
+ [_handlers removeAllObjects];
59
+ }
60
+
51
61
  @end
@@ -9,6 +9,8 @@ var React = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
+ var _init = require("./init");
13
+
12
14
  var _utils = require("./utils");
13
15
 
14
16
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -16,9 +18,13 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
16
18
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
19
 
18
20
  /* eslint-disable @typescript-eslint/no-var-requires */
19
- const GestureHandlerRootViewNativeComponent = (0, _utils.isFabric)() ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerRootView');
21
+ const GestureHandlerRootViewNativeComponent = (0, _utils.shouldUseCodegenNativeComponent)() ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerRootView');
20
22
 
21
23
  function GestureHandlerRootView(props) {
24
+ // try initialize fabric on the first render, at this point we can
25
+ // reliably check if fabric is enabled (the function contains a flag
26
+ // to make sure it's called only once)
27
+ (0, _init.maybeInitializeFabric)();
22
28
  return /*#__PURE__*/React.createElement(GestureHandlerRootViewNativeComponent, props);
23
29
  }
24
30
  //# sourceMappingURL=GestureHandlerRootView.android.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;;;;;AAJA;AAMA,MAAMA,qCAAqC,GAAG,yBAC1CC,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADlB,GAE1C,yCAAuB,0BAAvB,CAFJ;;AAOe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,qCAAD,EAA2CA,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { isFabric } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = isFabric()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
1
+ {"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;;;;;AALA;AAOA,MAAMA,qCAAqC,GAAG,gDAC1CC,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADlB,GAE1C,yCAAuB,0BAAvB,CAFJ;;AAOe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACA;AAEA,sBAAO,oBAAC,qCAAD,EAA2CA,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\nimport { shouldUseCodegenNativeComponent } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
@@ -9,11 +9,17 @@ var React = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
+ var _init = require("./init");
13
+
12
14
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
15
 
14
16
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
17
 
16
18
  function GestureHandlerRootView(props) {
19
+ // try initialize fabric on the first render, at this point we can
20
+ // reliably check if fabric is enabled (the function contains a flag
21
+ // to make sure it's called only once)
22
+ (0, _init.maybeInitializeFabric)();
17
23
  return /*#__PURE__*/React.createElement(_reactNative.View, props);
18
24
  }
19
25
  //# sourceMappingURL=GestureHandlerRootView.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <View {...props} />;\n}\n"]}
1
+ {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACA;AAEA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <View {...props} />;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = GestureHandlerRootView;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
+
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ function GestureHandlerRootView(props) {
17
+ return /*#__PURE__*/React.createElement(_reactNative.View, props);
18
+ }
19
+ //# sourceMappingURL=GestureHandlerRootView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GestureHandlerRootView.web.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <View {...props} />;\n}\n"]}
@@ -19,6 +19,11 @@ if (RNGestureHandlerModule == null) {
19
19
  For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`.split('\n').map(line => line.trim()).join('\n')));
20
20
  }
21
21
 
22
+ if (RNGestureHandlerModule.flushOperations === undefined) {
23
+ RNGestureHandlerModule.flushOperations = () => {// NO-OP if not defined
24
+ };
25
+ }
26
+
22
27
  var _default = RNGestureHandlerModule;
23
28
  exports.default = _default;
24
29
  //# sourceMappingURL=RNGestureHandlerModule.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["RNGestureHandlerModule","NativeModules","console","error","split","map","line","trim","join"],"mappings":";;;;;;;AAAA;;AAEA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAA6BC,0BAAnC;;AAEA,IAAID,sBAAsB,IAAI,IAA9B,EAAoC;AAClCE,EAAAA,OAAO,CAACC,KAAR,CACE,uBACG;AACP;AACA,gIAFM,CAGGC,KAHH,CAGS,IAHT,EAIGC,GAJH,CAIQC,IAAD,IAAUA,IAAI,CAACC,IAAL,EAJjB,EAKGC,IALH,CAKQ,IALR,CADF,CADF;AAUD;;eAuBcR,sB","sourcesContent":["import { NativeModules } from 'react-native';\nimport { ActionType } from './ActionType';\nimport { tagMessage } from './utils';\nconst { RNGestureHandlerModule } = NativeModules;\n\nif (RNGestureHandlerModule == null) {\n console.error(\n tagMessage(\n `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).\n\n For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`\n .split('\\n')\n .map((line) => line.trim())\n .join('\\n')\n )\n );\n}\n\nexport type RNGestureHandlerModuleProps = {\n handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;\n handleClearJSResponder: () => void;\n createGestureHandler: (\n handlerName: string,\n handlerTag: number,\n config: Readonly<Record<string, unknown>>\n ) => void;\n attachGestureHandler: (\n handlerTag: number,\n newView: number,\n actionType: ActionType\n ) => void;\n updateGestureHandler: (\n handlerTag: number,\n newConfig: Readonly<Record<string, unknown>>\n ) => void;\n dropGestureHandler: (handlerTag: number) => void;\n install: () => void;\n};\n\nexport default RNGestureHandlerModule as RNGestureHandlerModuleProps;\n"]}
1
+ {"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["RNGestureHandlerModule","NativeModules","console","error","split","map","line","trim","join","flushOperations","undefined"],"mappings":";;;;;;;AAAA;;AAEA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAA6BC,0BAAnC;;AAEA,IAAID,sBAAsB,IAAI,IAA9B,EAAoC;AAClCE,EAAAA,OAAO,CAACC,KAAR,CACE,uBACG;AACP;AACA,gIAFM,CAGGC,KAHH,CAGS,IAHT,EAIGC,GAJH,CAIQC,IAAD,IAAUA,IAAI,CAACC,IAAL,EAJjB,EAKGC,IALH,CAKQ,IALR,CADF,CADF;AAUD;;AAED,IAAIR,sBAAsB,CAACS,eAAvB,KAA2CC,SAA/C,EAA0D;AACxDV,EAAAA,sBAAsB,CAACS,eAAvB,GAAyC,MAAM,CAC7C;AACD,GAFD;AAGD;;eAwBcT,sB","sourcesContent":["import { NativeModules } from 'react-native';\nimport { ActionType } from './ActionType';\nimport { tagMessage } from './utils';\nconst { RNGestureHandlerModule } = NativeModules;\n\nif (RNGestureHandlerModule == null) {\n console.error(\n tagMessage(\n `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).\n\n For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`\n .split('\\n')\n .map((line) => line.trim())\n .join('\\n')\n )\n );\n}\n\nif (RNGestureHandlerModule.flushOperations === undefined) {\n RNGestureHandlerModule.flushOperations = () => {\n // NO-OP if not defined\n };\n}\n\nexport type RNGestureHandlerModuleProps = {\n handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;\n handleClearJSResponder: () => void;\n createGestureHandler: (\n handlerName: string,\n handlerTag: number,\n config: Readonly<Record<string, unknown>>\n ) => void;\n attachGestureHandler: (\n handlerTag: number,\n newView: number,\n actionType: ActionType\n ) => void;\n updateGestureHandler: (\n handlerTag: number,\n newConfig: Readonly<Record<string, unknown>>\n ) => void;\n dropGestureHandler: (handlerTag: number) => void;\n install: () => void;\n flushOperations: () => void;\n};\n\nexport default RNGestureHandlerModule as RNGestureHandlerModuleProps;\n"]}
@@ -73,7 +73,10 @@ var _default = {
73
73
 
74
74
  dropGestureHandler(handlerTag) {
75
75
  NodeManager.dropGestureHandler(handlerTag);
76
- }
76
+ },
77
+
78
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
79
+ flushOperations() {}
77
80
 
78
81
  };
79
82
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["Gestures","PanGestureHandler","RotationGestureHandler","PinchGestureHandler","TapGestureHandler","NativeViewGestureHandler","LongPressGestureHandler","FlingGestureHandler","Direction","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","NodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","getHandler","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,iBAAiB,EAAjBA,0BADsB;AAEtBC,EAAAA,sBAAsB,EAAtBA,+BAFsB;AAGtBC,EAAAA,mBAAmB,EAAnBA,4BAHsB;AAItBC,EAAAA,iBAAiB,EAAjBA,0BAJsB;AAKtBC,EAAAA,wBAAwB,EAAxBA,iCALsB;AAMtBC,EAAAA,uBAAuB,EAAvBA,gCANsB;AAOtBC,EAAAA,mBAAmB,EAAnBA,4BAPsB,CAQtB;;AARsB,CAAjB;;eAWQ;AACbC,EAAAA,SAAS,EAATA,oBADa;;AAEbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAJY;;AAKbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GAPY;;AAQbE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA;AACA,QAAI,EAAEF,WAAW,IAAIhB,QAAjB,CAAJ,EACE,MAAM,IAAImB,KAAJ,CACH,iCAAgCH,WAAY,2BADzC,CAAN;AAGF,UAAMI,YAAY,GAAGpB,QAAQ,CAACgB,WAAD,CAA7B;AACAK,IAAAA,WAAW,CAACN,oBAAZ,CAAiCE,UAAjC,EAA6C,IAAIG,YAAJ,EAA7C;AACA,SAAKE,oBAAL,CAA0BL,UAA1B,EAAsCC,MAAtC;AACD,GArBY;;AAsBbK,EAAAA,oBAAoB,CAClBN,UADkB,EAElBO,OAFkB,EAGlBC,WAHkB,EAIlBC,QAJkB,EAKlB;AACAL,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCW,OAAnC,CAA2CJ,OAA3C,EAAoDE,QAApD;AACD,GA7BY;;AA8BbJ,EAAAA,oBAAoB,CAACL,UAAD,EAAqBY,SAArB,EAAqC;AACvDR,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCa,mBAAnC,CAAuDD,SAAvD;AACD,GAhCY;;AAiCbE,EAAAA,qBAAqB,CAACd,UAAD,EAAqB;AACxC,WAAOI,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,CAAP;AACD,GAnCY;;AAoCbe,EAAAA,kBAAkB,CAACf,UAAD,EAAqB;AACrCI,IAAAA,WAAW,CAACW,kBAAZ,CAA+Bf,UAA/B;AACD;;AAtCY,C","sourcesContent":["import { ActionType } from './ActionType';\nimport { Direction } from './web/constants';\nimport FlingGestureHandler from './web/FlingGestureHandler';\nimport LongPressGestureHandler from './web/LongPressGestureHandler';\nimport NativeViewGestureHandler from './web/NativeViewGestureHandler';\nimport * as NodeManager from './web/NodeManager';\nimport PanGestureHandler from './web/PanGestureHandler';\nimport PinchGestureHandler from './web/PinchGestureHandler';\nimport RotationGestureHandler from './web/RotationGestureHandler';\nimport TapGestureHandler from './web/TapGestureHandler';\n\nexport const Gestures = {\n PanGestureHandler,\n RotationGestureHandler,\n PinchGestureHandler,\n TapGestureHandler,\n NativeViewGestureHandler,\n LongPressGestureHandler,\n FlingGestureHandler,\n // ForceTouchGestureHandler,\n};\n\nexport default {\n Direction,\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n //TODO(TS) extends config\n if (!(handlerName in Gestures))\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(handlerTag, new GestureClass());\n this.updateGestureHandler(handlerTag, config);\n },\n attachGestureHandler(\n handlerTag: number,\n newView: number,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n NodeManager.getHandler(handlerTag).setView(newView, propsRef);\n },\n updateGestureHandler(handlerTag: number, newConfig: any) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n },\n getGestureHandlerNode(handlerTag: number) {\n return NodeManager.getHandler(handlerTag);\n },\n dropGestureHandler(handlerTag: number) {\n NodeManager.dropGestureHandler(handlerTag);\n },\n};\n"]}
1
+ {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["Gestures","PanGestureHandler","RotationGestureHandler","PinchGestureHandler","TapGestureHandler","NativeViewGestureHandler","LongPressGestureHandler","FlingGestureHandler","Direction","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","NodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","getHandler","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,iBAAiB,EAAjBA,0BADsB;AAEtBC,EAAAA,sBAAsB,EAAtBA,+BAFsB;AAGtBC,EAAAA,mBAAmB,EAAnBA,4BAHsB;AAItBC,EAAAA,iBAAiB,EAAjBA,0BAJsB;AAKtBC,EAAAA,wBAAwB,EAAxBA,iCALsB;AAMtBC,EAAAA,uBAAuB,EAAvBA,gCANsB;AAOtBC,EAAAA,mBAAmB,EAAnBA,4BAPsB,CAQtB;;AARsB,CAAjB;;eAWQ;AACbC,EAAAA,SAAS,EAATA,oBADa;;AAEbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAJY;;AAKbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GAPY;;AAQbE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA;AACA,QAAI,EAAEF,WAAW,IAAIhB,QAAjB,CAAJ,EACE,MAAM,IAAImB,KAAJ,CACH,iCAAgCH,WAAY,2BADzC,CAAN;AAGF,UAAMI,YAAY,GAAGpB,QAAQ,CAACgB,WAAD,CAA7B;AACAK,IAAAA,WAAW,CAACN,oBAAZ,CAAiCE,UAAjC,EAA6C,IAAIG,YAAJ,EAA7C;AACA,SAAKE,oBAAL,CAA0BL,UAA1B,EAAsCC,MAAtC;AACD,GArBY;;AAsBbK,EAAAA,oBAAoB,CAClBN,UADkB,EAElBO,OAFkB,EAGlBC,WAHkB,EAIlBC,QAJkB,EAKlB;AACAL,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCW,OAAnC,CAA2CJ,OAA3C,EAAoDE,QAApD;AACD,GA7BY;;AA8BbJ,EAAAA,oBAAoB,CAACL,UAAD,EAAqBY,SAArB,EAAqC;AACvDR,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCa,mBAAnC,CAAuDD,SAAvD;AACD,GAhCY;;AAiCbE,EAAAA,qBAAqB,CAACd,UAAD,EAAqB;AACxC,WAAOI,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,CAAP;AACD,GAnCY;;AAoCbe,EAAAA,kBAAkB,CAACf,UAAD,EAAqB;AACrCI,IAAAA,WAAW,CAACW,kBAAZ,CAA+Bf,UAA/B;AACD,GAtCY;;AAuCb;AACAgB,EAAAA,eAAe,GAAG,CAAE;;AAxCP,C","sourcesContent":["import { ActionType } from './ActionType';\nimport { Direction } from './web/constants';\nimport FlingGestureHandler from './web/FlingGestureHandler';\nimport LongPressGestureHandler from './web/LongPressGestureHandler';\nimport NativeViewGestureHandler from './web/NativeViewGestureHandler';\nimport * as NodeManager from './web/NodeManager';\nimport PanGestureHandler from './web/PanGestureHandler';\nimport PinchGestureHandler from './web/PinchGestureHandler';\nimport RotationGestureHandler from './web/RotationGestureHandler';\nimport TapGestureHandler from './web/TapGestureHandler';\n\nexport const Gestures = {\n PanGestureHandler,\n RotationGestureHandler,\n PinchGestureHandler,\n TapGestureHandler,\n NativeViewGestureHandler,\n LongPressGestureHandler,\n FlingGestureHandler,\n // ForceTouchGestureHandler,\n};\n\nexport default {\n Direction,\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n //TODO(TS) extends config\n if (!(handlerName in Gestures))\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(handlerTag, new GestureClass());\n this.updateGestureHandler(handlerTag, config);\n },\n attachGestureHandler(\n handlerTag: number,\n newView: number,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n NodeManager.getHandler(handlerTag).setView(newView, propsRef);\n },\n updateGestureHandler(handlerTag: number, newConfig: any) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n },\n getGestureHandlerNode(handlerTag: number) {\n return NodeManager.getHandler(handlerTag);\n },\n dropGestureHandler(handlerTag: number) {\n NodeManager.dropGestureHandler(handlerTag);\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n flushOperations() {},\n};\n"]}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.EventType = void 0;
7
- const EventType = {
6
+ exports.TouchEventType = void 0;
7
+ const TouchEventType = {
8
8
  UNDETERMINED: 0,
9
9
  TOUCHES_DOWN: 1,
10
10
  TOUCHES_MOVE: 2,
@@ -12,5 +12,5 @@ const EventType = {
12
12
  TOUCHES_CANCELLED: 4
13
13
  }; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
14
14
 
15
- exports.EventType = EventType;
16
- //# sourceMappingURL=EventType.js.map
15
+ exports.TouchEventType = TouchEventType;
16
+ //# sourceMappingURL=TouchEventType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TouchEventType.ts"],"names":["TouchEventType","UNDETERMINED","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED"],"mappings":";;;;;;AAAO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,YAAY,EAAE,CADc;AAE5BC,EAAAA,YAAY,EAAE,CAFc;AAG5BC,EAAAA,YAAY,EAAE,CAHc;AAI5BC,EAAAA,UAAU,EAAE,CAJgB;AAK5BC,EAAAA,iBAAiB,EAAE;AALS,CAAvB,C,CAQP","sourcesContent":["export const TouchEventType = {\n UNDETERMINED: 0,\n TOUCHES_DOWN: 1,\n TOUCHES_MOVE: 2,\n TOUCHES_UP: 3,\n TOUCHES_CANCELLED: 4,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type TouchEventType = typeof TouchEventType[keyof typeof TouchEventType];\n"]}
@@ -165,6 +165,9 @@ class DrawerLayout extends React.Component {
165
165
  });
166
166
  } else if (nativeEvent.state === _State.State.ACTIVE) {
167
167
  this.emitStateChanged(DRAGGING, false);
168
+ this.setState({
169
+ drawerState: DRAGGING
170
+ });
168
171
 
169
172
  if (this.props.keyboardDismissMode === 'on-drag') {
170
173
  _reactNative.Keyboard.dismiss();
@@ -289,6 +292,9 @@ class DrawerLayout extends React.Component {
289
292
  const willShow = toValue !== 0;
290
293
  this.updateShowing(willShow);
291
294
  this.emitStateChanged(SETTLING, willShow);
295
+ this.setState({
296
+ drawerState: SETTLING
297
+ });
292
298
 
293
299
  if (this.props.hideStatusBar) {
294
300
  _reactNative.StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');
@@ -305,6 +311,17 @@ class DrawerLayout extends React.Component {
305
311
  }) => {
306
312
  if (finished) {
307
313
  this.emitStateChanged(IDLE, willShow);
314
+ this.setState({
315
+ drawerOpened: willShow
316
+ });
317
+
318
+ if (this.state.drawerState !== DRAGGING) {
319
+ // it's possilbe that user started drag while the drawer
320
+ // was settling, don't override state in this case
321
+ this.setState({
322
+ drawerState: IDLE
323
+ });
324
+ }
308
325
 
309
326
  if (willShow) {
310
327
  var _this$props$onDrawerO, _this$props3;
@@ -338,11 +355,14 @@ class DrawerLayout extends React.Component {
338
355
  _defineProperty(this, "renderOverlay", () => {
339
356
  /* Overlay styles */
340
357
  (0, _invariant.default)(this.openValue, 'should be set');
341
- const overlayOpacity = this.openValue.interpolate({
342
- inputRange: [0, 1],
343
- outputRange: [0, 1],
344
- extrapolate: 'clamp'
345
- });
358
+ let overlayOpacity;
359
+
360
+ if (this.state.drawerState !== IDLE) {
361
+ overlayOpacity = this.openValue;
362
+ } else {
363
+ overlayOpacity = this.state.drawerOpened ? 1 : 0;
364
+ }
365
+
346
366
  const dynamicOverlayStyles = {
347
367
  opacity: overlayOpacity,
348
368
  backgroundColor: this.props.overlayColor
@@ -398,11 +418,16 @@ class DrawerLayout extends React.Component {
398
418
 
399
419
  if (drawerSlide) {
400
420
  const closedDrawerOffset = fromLeft ? -drawerWidth : drawerWidth;
401
- drawerTranslateX = openValue.interpolate({
402
- inputRange: [0, 1],
403
- outputRange: [closedDrawerOffset, 0],
404
- extrapolate: 'clamp'
405
- });
421
+
422
+ if (this.state.drawerState !== IDLE) {
423
+ drawerTranslateX = openValue.interpolate({
424
+ inputRange: [0, 1],
425
+ outputRange: [closedDrawerOffset, 0],
426
+ extrapolate: 'clamp'
427
+ });
428
+ } else {
429
+ drawerTranslateX = this.state.drawerOpened ? 0 : closedDrawerOffset;
430
+ }
406
431
  }
407
432
 
408
433
  const drawerStyles = {
@@ -446,7 +471,9 @@ class DrawerLayout extends React.Component {
446
471
  dragX: _dragX,
447
472
  touchX: _touchX,
448
473
  drawerTranslation: _drawerTranslation,
449
- containerWidth: 0
474
+ containerWidth: 0,
475
+ drawerState: IDLE,
476
+ drawerOpened: false
450
477
  };
451
478
  this.updateAnimatedEvent(_props, this.state);
452
479
  }