react-native-gesture-handler 2.8.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. package/README.md +1 -0
  2. package/RNGestureHandler.podspec +2 -2
  3. package/android/build.gradle +107 -65
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +1 -1
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +39 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -2
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +14 -2
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +5 -1
  10. package/android/src/main/jni/CMakeLists.txt +10 -44
  11. package/android/src/main/jni/cpp-adapter.cpp +16 -13
  12. package/ios/Handlers/RNFlingHandler.m +39 -37
  13. package/ios/Handlers/RNForceTouchHandler.m +19 -17
  14. package/ios/Handlers/RNLongPressHandler.m +20 -22
  15. package/ios/Handlers/RNManualHandler.m +2 -3
  16. package/ios/Handlers/RNNativeViewHandler.mm +96 -92
  17. package/ios/Handlers/RNPanHandler.m +28 -32
  18. package/ios/Handlers/RNPinchHandler.m +9 -10
  19. package/ios/Handlers/RNRotationHandler.m +11 -14
  20. package/ios/Handlers/RNTapHandler.m +26 -26
  21. package/ios/RNGestureHandler.h +31 -24
  22. package/ios/RNGestureHandler.m +278 -273
  23. package/ios/RNGestureHandlerActionType.h +6 -4
  24. package/ios/RNGestureHandlerButton.m +11 -12
  25. package/ios/RNGestureHandlerButtonComponentView.h +2 -2
  26. package/ios/RNGestureHandlerButtonComponentView.mm +2 -2
  27. package/ios/RNGestureHandlerButtonManager.m +6 -5
  28. package/ios/RNGestureHandlerDirection.h +4 -4
  29. package/ios/RNGestureHandlerEvents.h +3 -4
  30. package/ios/RNGestureHandlerEvents.m +114 -119
  31. package/ios/RNGestureHandlerManager.h +1 -2
  32. package/ios/RNGestureHandlerManager.mm +9 -9
  33. package/ios/RNGestureHandlerModule.h +1 -2
  34. package/ios/RNGestureHandlerModule.mm +142 -138
  35. package/ios/RNGestureHandlerPointerTracker.h +1 -1
  36. package/ios/RNGestureHandlerPointerTracker.m +40 -37
  37. package/ios/RNGestureHandlerRegistry.h +3 -1
  38. package/ios/RNGestureHandlerRegistry.m +24 -22
  39. package/ios/RNGestureHandlerRootViewComponentView.mm +2 -2
  40. package/ios/RNGestureHandlerState.h +6 -6
  41. package/ios/RNGestureHandlerStateManager.h +1 -1
  42. package/ios/RNManualActivationRecognizer.m +9 -9
  43. package/ios/RNRootViewGestureRecognizer.m +39 -42
  44. package/lib/commonjs/EnableNewWebImplementation.js +35 -0
  45. package/lib/commonjs/EnableNewWebImplementation.js.map +1 -0
  46. package/lib/commonjs/GestureHandlerRootViewContext.js +15 -0
  47. package/lib/commonjs/GestureHandlerRootViewContext.js.map +1 -0
  48. package/lib/commonjs/RNGestureHandlerModule.macos.js +6 -6
  49. package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
  50. package/lib/commonjs/RNGestureHandlerModule.web.js +6 -6
  51. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  52. package/lib/commonjs/RNGestureHandlerModule.windows.js +6 -6
  53. package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
  54. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  55. package/lib/commonjs/components/GestureComponents.web.js +6 -5
  56. package/lib/commonjs/components/GestureComponents.web.js.map +1 -1
  57. package/lib/commonjs/components/GestureHandlerButton.js +3 -5
  58. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  59. package/lib/commonjs/{GestureHandlerRootView.android.js → components/GestureHandlerRootView.android.js} +8 -7
  60. package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -0
  61. package/lib/commonjs/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +8 -2
  62. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -0
  63. package/lib/commonjs/{GestureHandlerRootView.web.js → components/GestureHandlerRootView.web.js} +7 -1
  64. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
  65. package/lib/commonjs/components/Swipeable.js +17 -3
  66. package/lib/commonjs/components/Swipeable.js.map +1 -1
  67. package/lib/commonjs/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +2 -1
  68. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -0
  69. package/lib/commonjs/handlers/LongPressGestureHandler.js +3 -1
  70. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  71. package/lib/commonjs/handlers/TapGestureHandler.js +3 -1
  72. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  73. package/lib/commonjs/handlers/createHandler.js +21 -13
  74. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  75. package/lib/commonjs/handlers/gestureHandlerCommon.js +5 -4
  76. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  77. package/lib/commonjs/handlers/gestures/GestureDetector.js +89 -37
  78. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  79. package/lib/commonjs/handlers/gestures/longPressGesture.js +1 -0
  80. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
  81. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +22 -19
  82. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  83. package/lib/commonjs/handlers/gestures/tapGesture.js +1 -0
  84. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
  85. package/lib/commonjs/index.js +16 -4
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/utils.js +0 -6
  88. package/lib/commonjs/utils.js.map +1 -1
  89. package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -5
  90. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  91. package/lib/commonjs/web/handlers/GestureHandler.js +3 -0
  92. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  93. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +0 -1
  94. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  95. package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -5
  96. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  97. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +0 -6
  98. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  99. package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -12
  100. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  101. package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -5
  102. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  103. package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -6
  104. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  105. package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -7
  106. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  107. package/lib/commonjs/web/tools/CircularBuffer.js +59 -0
  108. package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -0
  109. package/lib/commonjs/web/tools/LeastSquareSolver.js +204 -0
  110. package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -0
  111. package/lib/commonjs/web/tools/PointerEventManager.js +27 -0
  112. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  113. package/lib/commonjs/web/tools/PointerTracker.js +11 -7
  114. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  115. package/lib/commonjs/web/tools/VelocityTracker.js +111 -0
  116. package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -0
  117. package/lib/commonjs/web_hammer/GestureHandler.js +1 -1
  118. package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
  119. package/lib/module/EnableNewWebImplementation.js +22 -0
  120. package/lib/module/EnableNewWebImplementation.js.map +1 -0
  121. package/lib/module/GestureHandlerRootViewContext.js +3 -0
  122. package/lib/module/GestureHandlerRootViewContext.js.map +1 -0
  123. package/lib/module/RNGestureHandlerModule.macos.js +6 -6
  124. package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
  125. package/lib/module/RNGestureHandlerModule.web.js +6 -6
  126. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  127. package/lib/module/RNGestureHandlerModule.windows.js +6 -6
  128. package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
  129. package/lib/module/components/DrawerLayout.js.map +1 -1
  130. package/lib/module/components/GestureComponents.web.js +5 -6
  131. package/lib/module/components/GestureComponents.web.js.map +1 -1
  132. package/lib/module/components/GestureHandlerButton.js +1 -4
  133. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  134. package/lib/module/components/GestureHandlerRootView.android.js +14 -0
  135. package/lib/module/components/GestureHandlerRootView.android.js.map +1 -0
  136. package/lib/module/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +5 -2
  137. package/lib/module/components/GestureHandlerRootView.js.map +1 -0
  138. package/lib/module/components/GestureHandlerRootView.web.js +9 -0
  139. package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
  140. package/lib/module/components/Swipeable.js +17 -3
  141. package/lib/module/components/Swipeable.js.map +1 -1
  142. package/lib/module/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +2 -1
  143. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -0
  144. package/lib/module/handlers/LongPressGestureHandler.js +3 -1
  145. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  146. package/lib/module/handlers/TapGestureHandler.js +3 -1
  147. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  148. package/lib/module/handlers/createHandler.js +20 -13
  149. package/lib/module/handlers/createHandler.js.map +1 -1
  150. package/lib/module/handlers/gestureHandlerCommon.js +5 -4
  151. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  152. package/lib/module/handlers/gestures/GestureDetector.js +89 -38
  153. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  154. package/lib/module/handlers/gestures/longPressGesture.js +1 -0
  155. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  156. package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -16
  157. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  158. package/lib/module/handlers/gestures/tapGesture.js +1 -0
  159. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  160. package/lib/module/index.js +4 -4
  161. package/lib/module/index.js.map +1 -1
  162. package/lib/module/utils.js +0 -4
  163. package/lib/module/utils.js.map +1 -1
  164. package/lib/module/web/handlers/FlingGestureHandler.js +0 -5
  165. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/GestureHandler.js +3 -0
  167. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/LongPressGestureHandler.js +0 -1
  169. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/ManualGestureHandler.js +0 -5
  171. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  172. package/lib/module/web/handlers/NativeViewGestureHandler.js +0 -6
  173. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  174. package/lib/module/web/handlers/PanGestureHandler.js +2 -9
  175. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  176. package/lib/module/web/handlers/PinchGestureHandler.js +0 -5
  177. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  178. package/lib/module/web/handlers/RotationGestureHandler.js +0 -6
  179. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  180. package/lib/module/web/handlers/TapGestureHandler.js +0 -7
  181. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  182. package/lib/module/web/tools/CircularBuffer.js +50 -0
  183. package/lib/module/web/tools/CircularBuffer.js.map +1 -0
  184. package/lib/module/web/tools/LeastSquareSolver.js +195 -0
  185. package/lib/module/web/tools/LeastSquareSolver.js.map +1 -0
  186. package/lib/module/web/tools/PointerEventManager.js +27 -0
  187. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  188. package/lib/module/web/tools/PointerTracker.js +8 -7
  189. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  190. package/lib/module/web/tools/VelocityTracker.js +98 -0
  191. package/lib/module/web/tools/VelocityTracker.js.map +1 -0
  192. package/lib/module/web_hammer/GestureHandler.js +1 -1
  193. package/lib/module/web_hammer/GestureHandler.js.map +1 -1
  194. package/lib/typescript/EnableNewWebImplementation.d.ts +3 -0
  195. package/lib/typescript/GestureHandlerRootViewContext.d.ts +3 -0
  196. package/lib/typescript/components/DrawerLayout.d.ts +3 -1
  197. package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
  198. package/lib/typescript/components/Swipeable.d.ts +14 -2
  199. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +3 -0
  200. package/lib/typescript/index.d.ts +4 -4
  201. package/lib/typescript/{fabric → specs}/RNGestureHandlerButtonNativeComponent.d.ts +1 -1
  202. package/lib/typescript/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.d.ts +1 -1
  203. package/lib/typescript/utils.d.ts +0 -1
  204. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
  205. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
  206. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
  207. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -1
  208. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
  209. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
  210. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -1
  211. package/lib/typescript/web/tools/CircularBuffer.d.ts +11 -0
  212. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +12 -0
  213. package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
  214. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  215. package/lib/typescript/web/tools/VelocityTracker.d.ts +13 -0
  216. package/package.json +6 -7
  217. package/src/EnableNewWebImplementation.ts +35 -0
  218. package/src/GestureHandlerRootViewContext.ts +3 -0
  219. package/src/RNGestureHandlerModule.macos.ts +6 -6
  220. package/src/RNGestureHandlerModule.web.ts +6 -6
  221. package/src/RNGestureHandlerModule.windows.ts +6 -6
  222. package/src/components/DrawerLayout.tsx +8 -4
  223. package/src/components/GestureComponents.web.tsx +5 -6
  224. package/src/components/GestureHandlerButton.tsx +2 -7
  225. package/src/components/GestureHandlerRootView.android.tsx +24 -0
  226. package/src/{GestureHandlerRootView.tsx → components/GestureHandlerRootView.tsx} +7 -2
  227. package/src/{GestureHandlerRootView.web.tsx → components/GestureHandlerRootView.web.tsx} +6 -1
  228. package/src/components/Swipeable.tsx +43 -12
  229. package/src/{gestureHandlerRootHOC.tsx → components/gestureHandlerRootHOC.tsx} +4 -1
  230. package/src/handlers/LongPressGestureHandler.ts +3 -1
  231. package/src/handlers/TapGestureHandler.ts +3 -1
  232. package/src/handlers/createHandler.tsx +20 -9
  233. package/src/handlers/gestureHandlerCommon.ts +5 -6
  234. package/src/handlers/gestures/GestureDetector.tsx +99 -36
  235. package/src/handlers/gestures/longPressGesture.ts +1 -0
  236. package/src/handlers/gestures/reanimatedWrapper.ts +21 -20
  237. package/src/handlers/gestures/tapGesture.ts +1 -0
  238. package/src/index.ts +7 -3
  239. package/src/utils.ts +0 -5
  240. package/src/web/handlers/FlingGestureHandler.ts +0 -5
  241. package/src/web/handlers/GestureHandler.ts +3 -0
  242. package/src/web/handlers/LongPressGestureHandler.ts +0 -1
  243. package/src/web/handlers/ManualGestureHandler.ts +0 -5
  244. package/src/web/handlers/NativeViewGestureHandler.ts +0 -6
  245. package/src/web/handlers/PanGestureHandler.ts +2 -9
  246. package/src/web/handlers/PinchGestureHandler.ts +0 -5
  247. package/src/web/handlers/RotationGestureHandler.ts +0 -7
  248. package/src/web/handlers/TapGestureHandler.ts +0 -7
  249. package/src/web/tools/CircularBuffer.ts +42 -0
  250. package/src/web/tools/LeastSquareSolver.ts +182 -0
  251. package/src/web/tools/PointerEventManager.ts +29 -0
  252. package/src/web/tools/PointerTracker.ts +7 -7
  253. package/src/web/tools/VelocityTracker.ts +98 -0
  254. package/src/web_hammer/GestureHandler.ts +1 -1
  255. package/lib/commonjs/EnableExperimentalWebImplementation.js +0 -31
  256. package/lib/commonjs/EnableExperimentalWebImplementation.js.map +0 -1
  257. package/lib/commonjs/GestureHandlerRootView.android.js.map +0 -1
  258. package/lib/commonjs/GestureHandlerRootView.js.map +0 -1
  259. package/lib/commonjs/GestureHandlerRootView.web.js.map +0 -1
  260. package/lib/commonjs/gestureHandlerRootHOC.js.map +0 -1
  261. package/lib/module/EnableExperimentalWebImplementation.js +0 -20
  262. package/lib/module/EnableExperimentalWebImplementation.js.map +0 -1
  263. package/lib/module/GestureHandlerRootView.android.js +0 -14
  264. package/lib/module/GestureHandlerRootView.android.js.map +0 -1
  265. package/lib/module/GestureHandlerRootView.js.map +0 -1
  266. package/lib/module/GestureHandlerRootView.web.js +0 -6
  267. package/lib/module/GestureHandlerRootView.web.js.map +0 -1
  268. package/lib/module/gestureHandlerRootHOC.js.map +0 -1
  269. package/lib/typescript/EnableExperimentalWebImplementation.d.ts +0 -2
  270. package/lib/typescript/gestureHandlerRootHOC.d.ts +0 -3
  271. package/src/EnableExperimentalWebImplementation.ts +0 -27
  272. package/src/GestureHandlerRootView.android.tsx +0 -24
  273. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
  274. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
  275. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
  276. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
  277. /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
  278. /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
  279. /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
  280. /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
  281. /package/lib/typescript/{GestureHandlerRootView.android.d.ts → components/GestureHandlerRootView.android.d.ts} +0 -0
  282. /package/lib/typescript/{GestureHandlerRootView.d.ts → components/GestureHandlerRootView.d.ts} +0 -0
  283. /package/lib/typescript/{GestureHandlerRootView.web.d.ts → components/GestureHandlerRootView.web.d.ts} +0 -0
  284. /package/src/{fabric → specs}/RNGestureHandlerButtonNativeComponent.ts +0 -0
  285. /package/src/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.ts +0 -0
@@ -1,11 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import { View } from 'react-native';
3
- import { maybeInitializeFabric } from './init';
3
+ import { maybeInitializeFabric } from '../init';
4
+ import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
4
5
  export default function GestureHandlerRootView(props) {
5
6
  // try initialize fabric on the first render, at this point we can
6
7
  // reliably check if fabric is enabled (the function contains a flag
7
8
  // to make sure it's called only once)
8
9
  maybeInitializeFabric();
9
- return /*#__PURE__*/React.createElement(View, props);
10
+ return /*#__PURE__*/React.createElement(GestureHandlerRootViewContext.Provider, {
11
+ value: true
12
+ }, /*#__PURE__*/React.createElement(View, props));
10
13
  }
11
14
  //# sourceMappingURL=GestureHandlerRootView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["React","View","maybeInitializeFabric","GestureHandlerRootViewContext","GestureHandlerRootView","props"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,IAAT,QAAgC,cAAhC;AACA,SAASC,qBAAT,QAAsC,SAAtC;AACA,OAAOC,6BAAP,MAA0C,kCAA1C;AAKA,eAAe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACAH,EAAAA,qBAAqB;AAErB,sBACE,oBAAC,6BAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,IAAD,EAAUG,KAAV,CADF,CADF;AAKD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from '../init';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\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 (\n <GestureHandlerRootViewContext.Provider value>\n <View {...props} />\n </GestureHandlerRootViewContext.Provider>\n );\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
4
+ export default function GestureHandlerRootView(props) {
5
+ return /*#__PURE__*/React.createElement(GestureHandlerRootViewContext.Provider, {
6
+ value: true
7
+ }, /*#__PURE__*/React.createElement(View, props));
8
+ }
9
+ //# sourceMappingURL=GestureHandlerRootView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GestureHandlerRootView.web.tsx"],"names":["React","View","GestureHandlerRootViewContext","GestureHandlerRootView","props"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,IAAT,QAAgC,cAAhC;AACA,OAAOC,6BAAP,MAA0C,kCAA1C;AAKA,eAAe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA,sBACE,oBAAC,6BAAD,CAA+B,QAA/B;AAAwC,IAAA,KAAK;AAA7C,kBACE,oBAAC,IAAD,EAAUA,KAAV,CADF,CADF;AAKD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return (\n <GestureHandlerRootViewContext.Provider value>\n <View {...props} />\n </GestureHandlerRootViewContext.Provider>\n );\n}\n"]}
@@ -242,6 +242,18 @@ export default class Swipeable extends Component {
242
242
  this.animateRow(this.currentOffset(), -rightWidth);
243
243
  });
244
244
 
245
+ _defineProperty(this, "reset", () => {
246
+ const {
247
+ dragX,
248
+ rowTranslation
249
+ } = this.state;
250
+ dragX.setValue(0);
251
+ rowTranslation.setValue(0);
252
+ this.setState({
253
+ rowState: 0
254
+ });
255
+ });
256
+
245
257
  const _dragX = new Animated.Value(0);
246
258
 
247
259
  this.state = {
@@ -277,7 +289,9 @@ export default class Swipeable extends Component {
277
289
  const {
278
290
  children,
279
291
  renderLeftActions,
280
- renderRightActions
292
+ renderRightActions,
293
+ dragOffsetFromLeftEdge = 10,
294
+ dragOffsetFromRightEdge = 10
281
295
  } = this.props;
282
296
  const left = renderLeftActions && /*#__PURE__*/React.createElement(Animated.View, {
283
297
  style: [styles.leftActions, // all those and below parameters can have ! since they are all
@@ -288,7 +302,7 @@ export default class Swipeable extends Component {
288
302
  translateX: this.leftActionTranslate
289
303
  }]
290
304
  }]
291
- }, renderLeftActions(this.showLeftAction, this.transX), /*#__PURE__*/React.createElement(View, {
305
+ }, renderLeftActions(this.showLeftAction, this.transX, this), /*#__PURE__*/React.createElement(View, {
292
306
  onLayout: ({
293
307
  nativeEvent
294
308
  }) => this.setState({
@@ -309,7 +323,7 @@ export default class Swipeable extends Component {
309
323
  })
310
324
  }));
311
325
  return /*#__PURE__*/React.createElement(PanGestureHandler, _extends({
312
- activeOffsetX: [-10, 10]
326
+ activeOffsetX: [-dragOffsetFromRightEdge, dragOffsetFromLeftEdge]
313
327
  }, this.props, {
314
328
  onGestureEvent: this.onGestureEvent,
315
329
  onHandlerStateChange: this.onHandlerStateChange
@@ -1 +1 @@
1
- {"version":3,"sources":["Swipeable.tsx"],"names":["React","Component","Animated","StyleSheet","View","I18nManager","PanGestureHandler","TapGestureHandler","State","DRAG_TOSS","Swipeable","constructor","props","state","friction","overshootFriction","dragX","rowTranslation","leftWidth","rowWidth","rightOffset","rightWidth","Math","max","overshootLeft","overshootRight","transX","add","interpolate","inputRange","outputRange","showLeftAction","Value","leftActionTranslate","Number","MIN_VALUE","extrapolate","showRightAction","rightActionTranslate","nativeEvent","oldState","ACTIVE","close","ev","handleRelease","velocityX","translationX","rowState","leftThreshold","rightThreshold","startOffsetX","currentOffset","toValue","animateRow","fromValue","setValue","setState","sign","spring","restSpeedThreshold","restDisplacementThreshold","velocity","bounciness","useNativeDriver","useNativeAnimations","animationOptions","start","finished","onSwipeableLeftOpen","onSwipeableOpen","onSwipeableRightOpen","closingDirection","onSwipeableClose","onSwipeableLeftWillOpen","onSwipeableWillOpen","onSwipeableRightWillOpen","onSwipeableWillClose","layout","width","undefined","updateAnimatedEvent","onGestureEvent","event","shouldComponentUpdate","render","children","renderLeftActions","renderRightActions","left","styles","leftActions","transform","translateX","x","right","rightActions","onHandlerStateChange","onRowLayout","container","containerStyle","onTapHandlerStateChange","childrenContainerStyle","create","overflow","absoluteFillObject","flexDirection","isRTL"],"mappings":";;;;AAAA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;AACA,SACEC,QADF,EAEEC,UAFF,EAGEC,IAHF,EAIEC,WAJF,QAQO,cARP;AAcA,SACEC,iBADF,QAIO,+BAJP;AAKA,SACEC,iBADF,QAGO,+BAHP;AAIA,SAASC,KAAT,QAAsB,UAAtB;AAEA,MAAMC,SAAS,GAAG,IAAlB;AAqKA,eAAe,MAAMC,SAAN,SAAwBT,SAAxB,CAGb;AAOAU,EAAAA,WAAW,CAACC,MAAD,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b,OADK,EAIL,KAAKd,KAAL,CAAWyF,sBAJN;AAFT,OAQGhB,QARH,CAHF,CALF,CALF,CADF;AA4BD;;AAjTD;;gBAHmB3E,S,kBAIG;AACpBI,EAAAA,QAAQ,EAAE,CADU;AAEpBC,EAAAA,iBAAiB,EAAE,CAFC;AAGpBiD,EAAAA,mBAAmB,EAAE;AAHD,C;;AAmTxB,MAAMyB,MAAM,GAAGtF,UAAU,CAACmG,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/Bb,EAAAA,WAAW,EAAE,EACX,GAAGvF,UAAU,CAACqG,kBADH;AAEXC,IAAAA,aAAa,EAAEpG,WAAW,CAACqG,KAAZ,GAAoB,aAApB,GAAoC;AAFxC,GAJkB;AAQ/BX,EAAAA,YAAY,EAAE,EACZ,GAAG5F,UAAU,CAACqG,kBADF;AAEZC,IAAAA,aAAa,EAAEpG,WAAW,CAACqG,KAAZ,GAAoB,KAApB,GAA4B;AAF/B;AARiB,CAAlB,CAAf","sourcesContent":["// Similarily to the DrawerLayout component this deserves to be put in a\n// separate repo. Although, keeping it here for the time being will allow us to\n// move faster and fix possible issues quicker\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n I18nManager,\n LayoutChangeEvent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n PanGestureHandlerProps,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\ntype SwipeableExcludes = Exclude<\n keyof PanGestureHandlerProps,\n 'onGestureEvent' | 'onHandlerStateChange'\n>;\n\nexport interface SwipeableProps\n extends Pick<PanGestureHandlerProps, SwipeableExcludes> {\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance. e.g. value of 1 will indicate that the swipeable panel\n * should exactly follow the gesture, 2 means it is going to be two times\n * \"slower\".\n */\n friction?: number;\n\n /**\n * Distance from the left edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n leftThreshold?: number;\n\n /**\n * Distance from the right edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n rightThreshold?: number;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the left\n * actions panel's width. It is set to true by default as long as the left\n * panel render method is present.\n */\n overshootLeft?: boolean;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the\n * right actions panel's width. It is set to true by default as long as the\n * right panel render method is present.\n */\n overshootRight?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance at overshoot. Default value is 1, it mean no friction, for\n * a native feel, try 8 or above.\n */\n overshootFriction?: number;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableOpen()\n *\n * Called when left action panel gets open.\n */\n onSwipeableLeftOpen?: () => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableOpen()\n *\n * Called when right action panel gets open.\n */\n onSwipeableRightOpen?: () => void;\n\n /**\n * Called when action panel gets open (either right or left).\n */\n onSwipeableOpen?: (direction: 'left' | 'right', swipeable: Swipeable) => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: (\n direction: 'left' | 'right',\n swipeable: Swipeable\n ) => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableWillOpen()\n *\n * Called when left action panel starts animating on open.\n */\n onSwipeableLeftWillOpen?: () => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableWillOpen()\n *\n * Called when right action panel starts animating on open.\n */\n onSwipeableRightWillOpen?: () => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: (direction: 'left' | 'right') => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: (direction: 'left' | 'right') => void;\n\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progressAnimatedValue: Animated.AnimatedInterpolation,\n dragAnimatedValue: Animated.AnimatedInterpolation\n ) => React.ReactNode;\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progressAnimatedValue: Animated.AnimatedInterpolation,\n dragAnimatedValue: Animated.AnimatedInterpolation,\n swipeable: Swipeable\n ) => React.ReactNode;\n\n useNativeAnimations?: boolean;\n\n animationOptions?: Record<string, unknown>;\n\n /**\n * Style object for the container (`Animated.View`), for example to override\n * `overflow: 'hidden'`.\n */\n containerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Style object for the children container (`Animated.View`), for example to\n * apply `flex: 1`\n */\n childrenContainerStyle?: StyleProp<ViewStyle>;\n}\n\ntype SwipeableState = {\n dragX: Animated.Value;\n rowTranslation: Animated.Value;\n rowState: number;\n leftWidth?: number;\n rightOffset?: number;\n rowWidth?: number;\n};\n\nexport default class Swipeable extends Component<\n SwipeableProps,\n SwipeableState\n> {\n static defaultProps = {\n friction: 1,\n overshootFriction: 1,\n useNativeAnimations: true,\n };\n\n constructor(props: SwipeableProps) {\n super(props);\n const dragX = new Animated.Value(0);\n this.state = {\n dragX,\n rowTranslation: new Animated.Value(0),\n rowState: 0,\n leftWidth: undefined,\n rightOffset: undefined,\n rowWidth: undefined,\n };\n this.updateAnimatedEvent(props, this.state);\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragX } }],\n { useNativeDriver: props.useNativeAnimations! }\n );\n }\n\n shouldComponentUpdate(props: SwipeableProps, state: SwipeableState) {\n if (\n this.props.friction !== props.friction ||\n this.props.overshootLeft !== props.overshootLeft ||\n this.props.overshootRight !== props.overshootRight ||\n this.props.overshootFriction !== props.overshootFriction ||\n this.state.leftWidth !== state.leftWidth ||\n this.state.rightOffset !== state.rightOffset ||\n this.state.rowWidth !== state.rowWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n\n return true;\n }\n\n private onGestureEvent?: (\n event: GestureEvent<PanGestureHandlerEventPayload>\n ) => void;\n private transX?: Animated.AnimatedInterpolation;\n private showLeftAction?: Animated.AnimatedInterpolation | Animated.Value;\n private leftActionTranslate?: Animated.AnimatedInterpolation;\n private showRightAction?: Animated.AnimatedInterpolation | Animated.Value;\n private rightActionTranslate?: Animated.AnimatedInterpolation;\n\n private updateAnimatedEvent = (\n props: SwipeableProps,\n state: SwipeableState\n ) => {\n const { friction, overshootFriction } = props;\n const { dragX, rowTranslation, leftWidth = 0, rowWidth = 0 } = state;\n const { rightOffset = rowWidth } = state;\n const rightWidth = Math.max(0, rowWidth - rightOffset);\n\n const { overshootLeft = leftWidth > 0, overshootRight = rightWidth > 0 } =\n props;\n\n const transX = Animated.add(\n rowTranslation,\n dragX.interpolate({\n inputRange: [0, friction!],\n outputRange: [0, 1],\n })\n ).interpolate({\n inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],\n outputRange: [\n -rightWidth - (overshootRight ? 1 / overshootFriction! : 0),\n -rightWidth,\n leftWidth,\n leftWidth + (overshootLeft ? 1 / overshootFriction! : 0),\n ],\n });\n this.transX = transX;\n this.showLeftAction =\n leftWidth > 0\n ? transX.interpolate({\n inputRange: [-1, 0, leftWidth],\n outputRange: [0, 0, 1],\n })\n : new Animated.Value(0);\n this.leftActionTranslate = this.showLeftAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n this.showRightAction =\n rightWidth > 0\n ? transX.interpolate({\n inputRange: [-rightWidth, 0, 1],\n outputRange: [1, 0, 0],\n })\n : new Animated.Value(0);\n this.rightActionTranslate = this.showRightAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<TapGestureHandlerEventPayload>) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.close();\n }\n };\n\n private onHandlerStateChange = (\n ev: HandlerStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n if (ev.nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease(ev);\n }\n };\n\n private handleRelease = (\n ev: HandlerStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n const { velocityX, translationX: dragX } = ev.nativeEvent;\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n const {\n friction,\n leftThreshold = leftWidth / 2,\n rightThreshold = rightWidth / 2,\n } = this.props;\n\n const startOffsetX = this.currentOffset() + dragX / friction!;\n const translationX = (dragX + DRAG_TOSS * velocityX) / friction!;\n\n let toValue = 0;\n if (rowState === 0) {\n if (translationX > leftThreshold) {\n toValue = leftWidth;\n } else if (translationX < -rightThreshold) {\n toValue = -rightWidth;\n }\n } else if (rowState === 1) {\n // swiped to left\n if (translationX > -leftThreshold) {\n toValue = leftWidth;\n }\n } else {\n // swiped to right\n if (translationX < rightThreshold) {\n toValue = -rightWidth;\n }\n }\n\n this.animateRow(startOffsetX, toValue, velocityX / friction!);\n };\n\n private animateRow = (\n fromValue: number,\n toValue: number,\n velocityX?:\n | number\n | {\n x: number;\n y: number;\n }\n ) => {\n const { dragX, rowTranslation } = this.state;\n dragX.setValue(0);\n rowTranslation.setValue(fromValue);\n\n this.setState({ rowState: Math.sign(toValue) });\n Animated.spring(rowTranslation, {\n restSpeedThreshold: 1.7,\n restDisplacementThreshold: 0.4,\n velocity: velocityX,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n ...this.props.animationOptions,\n }).start(({ finished }) => {\n if (finished) {\n if (toValue > 0) {\n this.props.onSwipeableLeftOpen?.();\n this.props.onSwipeableOpen?.('left', this);\n } else if (toValue < 0) {\n this.props.onSwipeableRightOpen?.();\n this.props.onSwipeableOpen?.('right', this);\n } else {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n this.props.onSwipeableClose?.(closingDirection, this);\n }\n }\n });\n if (toValue > 0) {\n this.props.onSwipeableLeftWillOpen?.();\n this.props.onSwipeableWillOpen?.('left');\n } else if (toValue < 0) {\n this.props.onSwipeableRightWillOpen?.();\n this.props.onSwipeableWillOpen?.('right');\n } else {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n this.props.onSwipeableWillClose?.(closingDirection);\n }\n };\n\n private onRowLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ rowWidth: nativeEvent.layout.width });\n };\n\n private currentOffset = () => {\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n if (rowState === 1) {\n return leftWidth;\n } else if (rowState === -1) {\n return -rightWidth;\n }\n return 0;\n };\n\n close = () => {\n this.animateRow(this.currentOffset(), 0);\n };\n\n openLeft = () => {\n const { leftWidth = 0 } = this.state;\n this.animateRow(this.currentOffset(), leftWidth);\n };\n\n openRight = () => {\n const { rowWidth = 0 } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n this.animateRow(this.currentOffset(), -rightWidth);\n };\n\n render() {\n const { rowState } = this.state;\n const { children, renderLeftActions, renderRightActions } = this.props;\n\n const left = renderLeftActions && (\n <Animated.View\n style={[\n styles.leftActions,\n // all those and below parameters can have ! since they are all\n // asigned in constructor in `updateAnimatedEvent` but TS cannot spot\n // it for some reason\n { transform: [{ translateX: this.leftActionTranslate! }] },\n ]}>\n {renderLeftActions(this.showLeftAction!, this.transX!)}\n <View\n onLayout={({ nativeEvent }) =>\n this.setState({ leftWidth: nativeEvent.layout.x })\n }\n />\n </Animated.View>\n );\n\n const right = renderRightActions && (\n <Animated.View\n style={[\n styles.rightActions,\n { transform: [{ translateX: this.rightActionTranslate! }] },\n ]}>\n {renderRightActions(this.showRightAction!, this.transX!, this)}\n <View\n onLayout={({ nativeEvent }) =>\n this.setState({ rightOffset: nativeEvent.layout.x })\n }\n />\n </Animated.View>\n );\n\n return (\n <PanGestureHandler\n activeOffsetX={[-10, 10]}\n {...this.props}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}>\n <Animated.View\n onLayout={this.onRowLayout}\n style={[styles.container, this.props.containerStyle]}>\n {left}\n {right}\n <TapGestureHandler\n enabled={rowState !== 0}\n onHandlerStateChange={this.onTapHandlerStateChange}>\n <Animated.View\n pointerEvents={rowState === 0 ? 'auto' : 'box-only'}\n style={[\n {\n transform: [{ translateX: this.transX! }],\n },\n this.props.childrenContainerStyle,\n ]}>\n {children}\n </Animated.View>\n </TapGestureHandler>\n </Animated.View>\n </PanGestureHandler>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n leftActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',\n },\n rightActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',\n },\n});\n"]}
1
+ {"version":3,"sources":["Swipeable.tsx"],"names":["React","Component","Animated","StyleSheet","View","I18nManager","PanGestureHandler","TapGestureHandler","State","DRAG_TOSS","Swipeable","constructor","props","state","friction","overshootFriction","dragX","rowTranslation","leftWidth","rowWidth","rightOffset","rightWidth","Math","max","overshootLeft","overshootRight","transX","add","interpolate","inputRange","outputRange","showLeftAction","Value","leftActionTranslate","Number","MIN_VALUE","extrapolate","showRightAction","rightActionTranslate","nativeEvent","oldState","ACTIVE","close","ev","handleRelease","velocityX","translationX","rowState","leftThreshold","rightThreshold","startOffsetX","currentOffset","toValue","animateRow","fromValue","setValue","setState","sign","spring","restSpeedThreshold","restDisplacementThreshold","velocity","bounciness","useNativeDriver","useNativeAnimations","animationOptions","start","finished","onSwipeableLeftOpen","onSwipeableOpen","onSwipeableRightOpen","closingDirection","onSwipeableClose","onSwipeableLeftWillOpen","onSwipeableWillOpen","onSwipeableRightWillOpen","onSwipeableWillClose","layout","width","undefined","updateAnimatedEvent","onGestureEvent","event","shouldComponentUpdate","render","children","renderLeftActions","renderRightActions","dragOffsetFromLeftEdge","dragOffsetFromRightEdge","left","styles","leftActions","transform","translateX","x","right","rightActions","onHandlerStateChange","onRowLayout","container","containerStyle","onTapHandlerStateChange","childrenContainerStyle","create","overflow","absoluteFillObject","flexDirection","isRTL"],"mappings":";;;;AAAA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;AACA,SACEC,QADF,EAEEC,UAFF,EAGEC,IAHF,EAIEC,WAJF,QAQO,cARP;AAcA,SACEC,iBADF,QAIO,+BAJP;AAKA,SACEC,iBADF,QAGO,+BAHP;AAIA,SAASC,KAAT,QAAsB,UAAtB;AAEA,MAAMC,SAAS,GAAG,IAAlB;AAuLA,eAAe,MAAMC,SAAN,SAAwBT,SAAxB,CAGb;AAOAU,EAAAA,WAAW,CAACC,MAAD,EAAwB;AACjC,UAAMA,MAAN;;AADiC;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,iDA4CL,CAC5BA,KAD4B,EAE5BC,KAF4B,KAGzB;AACH,YAAM;AAAEC,QAAAA,QAAF;AAAYC,QAAAA;AAAZ,UAAkCH,KAA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AEvD,QAAQ,KAAK,CAAb,GAAiB,MAAjB,GAA0B,UAD3C;AAEE,MAAA,KAAK,EAAE,CACL;AACE8C,QAAAA,SAAS,EAAE,CAAC;AAAEC,UAAAA,UAAU,EAAE,KAAKpE;AAAnB,SAAD;AADb,OADK,EAIL,KAAKd,KAAL,CAAW2F,sBAJN;AAFT,OAQGlB,QARH,CAHF,CALF,CALF,CADF;AA4BD;;AA9TD;;gBAHmB3E,S,kBAIG;AACpBI,EAAAA,QAAQ,EAAE,CADU;AAEpBC,EAAAA,iBAAiB,EAAE,CAFC;AAGpBiD,EAAAA,mBAAmB,EAAE;AAHD,C;;AAgUxB,MAAM2B,MAAM,GAAGxF,UAAU,CAACqG,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/Bb,EAAAA,WAAW,EAAE,EACX,GAAGzF,UAAU,CAACuG,kBADH;AAEXC,IAAAA,aAAa,EAAEtG,WAAW,CAACuG,KAAZ,GAAoB,aAApB,GAAoC;AAFxC,GAJkB;AAQ/BX,EAAAA,YAAY,EAAE,EACZ,GAAG9F,UAAU,CAACuG,kBADF;AAEZC,IAAAA,aAAa,EAAEtG,WAAW,CAACuG,KAAZ,GAAoB,KAApB,GAA4B;AAF/B;AARiB,CAAlB,CAAf","sourcesContent":["// Similarily to the DrawerLayout component this deserves to be put in a\n// separate repo. Although, keeping it here for the time being will allow us to\n// move faster and fix possible issues quicker\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n I18nManager,\n LayoutChangeEvent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n PanGestureHandlerProps,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\ntype SwipeableExcludes = Exclude<\n keyof PanGestureHandlerProps,\n 'onGestureEvent' | 'onHandlerStateChange'\n>;\n\n// Animated.AnimatedInterpolation has been converted to a generic type\n// in @types/react-native 0.70. This way we can maintain compatibility\n// with all versions of @types/react-native\ntype AnimatedInterpolation = ReturnType<Animated.Value['interpolate']>;\n\nexport interface SwipeableProps\n extends Pick<PanGestureHandlerProps, SwipeableExcludes> {\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance. e.g. value of 1 will indicate that the swipeable panel\n * should exactly follow the gesture, 2 means it is going to be two times\n * \"slower\".\n */\n friction?: number;\n\n /**\n * Distance from the left edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n leftThreshold?: number;\n\n /**\n * Distance from the right edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n rightThreshold?: number;\n\n /**\n * Distance that the panel must be dragged from the left edge to be considered\n * a swipe. The default value is 10.\n */\n dragOffsetFromLeftEdge?: number;\n\n /**\n * Distance that the panel must be dragged from the right edge to be considered\n * a swipe. The default value is 10.\n */\n dragOffsetFromRightEdge?: number;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the left\n * actions panel's width. It is set to true by default as long as the left\n * panel render method is present.\n */\n overshootLeft?: boolean;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the\n * right actions panel's width. It is set to true by default as long as the\n * right panel render method is present.\n */\n overshootRight?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance at overshoot. Default value is 1, it mean no friction, for\n * a native feel, try 8 or above.\n */\n overshootFriction?: number;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableOpen()\n *\n * Called when left action panel gets open.\n */\n onSwipeableLeftOpen?: () => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableOpen()\n *\n * Called when right action panel gets open.\n */\n onSwipeableRightOpen?: () => void;\n\n /**\n * Called when action panel gets open (either right or left).\n */\n onSwipeableOpen?: (direction: 'left' | 'right', swipeable: Swipeable) => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: (\n direction: 'left' | 'right',\n swipeable: Swipeable\n ) => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableWillOpen()\n *\n * Called when left action panel starts animating on open.\n */\n onSwipeableLeftWillOpen?: () => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableWillOpen()\n *\n * Called when right action panel starts animating on open.\n */\n onSwipeableRightWillOpen?: () => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: (direction: 'left' | 'right') => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: (direction: 'left' | 'right') => void;\n\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progressAnimatedValue: AnimatedInterpolation,\n dragAnimatedValue: AnimatedInterpolation,\n swipeable: Swipeable\n ) => React.ReactNode;\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progressAnimatedValue: AnimatedInterpolation,\n dragAnimatedValue: AnimatedInterpolation,\n swipeable: Swipeable\n ) => React.ReactNode;\n\n useNativeAnimations?: boolean;\n\n animationOptions?: Record<string, unknown>;\n\n /**\n * Style object for the container (`Animated.View`), for example to override\n * `overflow: 'hidden'`.\n */\n containerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Style object for the children container (`Animated.View`), for example to\n * apply `flex: 1`\n */\n childrenContainerStyle?: StyleProp<ViewStyle>;\n}\n\ntype SwipeableState = {\n dragX: Animated.Value;\n rowTranslation: Animated.Value;\n rowState: number;\n leftWidth?: number;\n rightOffset?: number;\n rowWidth?: number;\n};\n\nexport default class Swipeable extends Component<\n SwipeableProps,\n SwipeableState\n> {\n static defaultProps = {\n friction: 1,\n overshootFriction: 1,\n useNativeAnimations: true,\n };\n\n constructor(props: SwipeableProps) {\n super(props);\n const dragX = new Animated.Value(0);\n this.state = {\n dragX,\n rowTranslation: new Animated.Value(0),\n rowState: 0,\n leftWidth: undefined,\n rightOffset: undefined,\n rowWidth: undefined,\n };\n this.updateAnimatedEvent(props, this.state);\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragX } }],\n { useNativeDriver: props.useNativeAnimations! }\n );\n }\n\n shouldComponentUpdate(props: SwipeableProps, state: SwipeableState) {\n if (\n this.props.friction !== props.friction ||\n this.props.overshootLeft !== props.overshootLeft ||\n this.props.overshootRight !== props.overshootRight ||\n this.props.overshootFriction !== props.overshootFriction ||\n this.state.leftWidth !== state.leftWidth ||\n this.state.rightOffset !== state.rightOffset ||\n this.state.rowWidth !== state.rowWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n\n return true;\n }\n\n private onGestureEvent?: (\n event: GestureEvent<PanGestureHandlerEventPayload>\n ) => void;\n private transX?: AnimatedInterpolation;\n private showLeftAction?: AnimatedInterpolation | Animated.Value;\n private leftActionTranslate?: AnimatedInterpolation;\n private showRightAction?: AnimatedInterpolation | Animated.Value;\n private rightActionTranslate?: AnimatedInterpolation;\n\n private updateAnimatedEvent = (\n props: SwipeableProps,\n state: SwipeableState\n ) => {\n const { friction, overshootFriction } = props;\n const { dragX, rowTranslation, leftWidth = 0, rowWidth = 0 } = state;\n const { rightOffset = rowWidth } = state;\n const rightWidth = Math.max(0, rowWidth - rightOffset);\n\n const { overshootLeft = leftWidth > 0, overshootRight = rightWidth > 0 } =\n props;\n\n const transX = Animated.add(\n rowTranslation,\n dragX.interpolate({\n inputRange: [0, friction!],\n outputRange: [0, 1],\n })\n ).interpolate({\n inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],\n outputRange: [\n -rightWidth - (overshootRight ? 1 / overshootFriction! : 0),\n -rightWidth,\n leftWidth,\n leftWidth + (overshootLeft ? 1 / overshootFriction! : 0),\n ],\n });\n this.transX = transX;\n this.showLeftAction =\n leftWidth > 0\n ? transX.interpolate({\n inputRange: [-1, 0, leftWidth],\n outputRange: [0, 0, 1],\n })\n : new Animated.Value(0);\n this.leftActionTranslate = this.showLeftAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n this.showRightAction =\n rightWidth > 0\n ? transX.interpolate({\n inputRange: [-rightWidth, 0, 1],\n outputRange: [1, 0, 0],\n })\n : new Animated.Value(0);\n this.rightActionTranslate = this.showRightAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<TapGestureHandlerEventPayload>) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.close();\n }\n };\n\n private onHandlerStateChange = (\n ev: HandlerStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n if (ev.nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease(ev);\n }\n };\n\n private handleRelease = (\n ev: HandlerStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n const { velocityX, translationX: dragX } = ev.nativeEvent;\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n const {\n friction,\n leftThreshold = leftWidth / 2,\n rightThreshold = rightWidth / 2,\n } = this.props;\n\n const startOffsetX = this.currentOffset() + dragX / friction!;\n const translationX = (dragX + DRAG_TOSS * velocityX) / friction!;\n\n let toValue = 0;\n if (rowState === 0) {\n if (translationX > leftThreshold) {\n toValue = leftWidth;\n } else if (translationX < -rightThreshold) {\n toValue = -rightWidth;\n }\n } else if (rowState === 1) {\n // swiped to left\n if (translationX > -leftThreshold) {\n toValue = leftWidth;\n }\n } else {\n // swiped to right\n if (translationX < rightThreshold) {\n toValue = -rightWidth;\n }\n }\n\n this.animateRow(startOffsetX, toValue, velocityX / friction!);\n };\n\n private animateRow = (\n fromValue: number,\n toValue: number,\n velocityX?:\n | number\n | {\n x: number;\n y: number;\n }\n ) => {\n const { dragX, rowTranslation } = this.state;\n dragX.setValue(0);\n rowTranslation.setValue(fromValue);\n\n this.setState({ rowState: Math.sign(toValue) });\n Animated.spring(rowTranslation, {\n restSpeedThreshold: 1.7,\n restDisplacementThreshold: 0.4,\n velocity: velocityX,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n ...this.props.animationOptions,\n }).start(({ finished }) => {\n if (finished) {\n if (toValue > 0) {\n this.props.onSwipeableLeftOpen?.();\n this.props.onSwipeableOpen?.('left', this);\n } else if (toValue < 0) {\n this.props.onSwipeableRightOpen?.();\n this.props.onSwipeableOpen?.('right', this);\n } else {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n this.props.onSwipeableClose?.(closingDirection, this);\n }\n }\n });\n if (toValue > 0) {\n this.props.onSwipeableLeftWillOpen?.();\n this.props.onSwipeableWillOpen?.('left');\n } else if (toValue < 0) {\n this.props.onSwipeableRightWillOpen?.();\n this.props.onSwipeableWillOpen?.('right');\n } else {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n this.props.onSwipeableWillClose?.(closingDirection);\n }\n };\n\n private onRowLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ rowWidth: nativeEvent.layout.width });\n };\n\n private currentOffset = () => {\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n if (rowState === 1) {\n return leftWidth;\n } else if (rowState === -1) {\n return -rightWidth;\n }\n return 0;\n };\n\n close = () => {\n this.animateRow(this.currentOffset(), 0);\n };\n\n openLeft = () => {\n const { leftWidth = 0 } = this.state;\n this.animateRow(this.currentOffset(), leftWidth);\n };\n\n openRight = () => {\n const { rowWidth = 0 } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n this.animateRow(this.currentOffset(), -rightWidth);\n };\n\n reset = () => {\n const { dragX, rowTranslation } = this.state;\n dragX.setValue(0);\n rowTranslation.setValue(0);\n this.setState({ rowState: 0 });\n };\n\n render() {\n const { rowState } = this.state;\n const {\n children,\n renderLeftActions,\n renderRightActions,\n dragOffsetFromLeftEdge = 10,\n dragOffsetFromRightEdge = 10,\n } = this.props;\n\n const left = renderLeftActions && (\n <Animated.View\n style={[\n styles.leftActions,\n // all those and below parameters can have ! since they are all\n // asigned in constructor in `updateAnimatedEvent` but TS cannot spot\n // it for some reason\n { transform: [{ translateX: this.leftActionTranslate! }] },\n ]}>\n {renderLeftActions(this.showLeftAction!, this.transX!, this)}\n <View\n onLayout={({ nativeEvent }) =>\n this.setState({ leftWidth: nativeEvent.layout.x })\n }\n />\n </Animated.View>\n );\n\n const right = renderRightActions && (\n <Animated.View\n style={[\n styles.rightActions,\n { transform: [{ translateX: this.rightActionTranslate! }] },\n ]}>\n {renderRightActions(this.showRightAction!, this.transX!, this)}\n <View\n onLayout={({ nativeEvent }) =>\n this.setState({ rightOffset: nativeEvent.layout.x })\n }\n />\n </Animated.View>\n );\n\n return (\n <PanGestureHandler\n activeOffsetX={[-dragOffsetFromRightEdge, dragOffsetFromLeftEdge]}\n {...this.props}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}>\n <Animated.View\n onLayout={this.onRowLayout}\n style={[styles.container, this.props.containerStyle]}>\n {left}\n {right}\n <TapGestureHandler\n enabled={rowState !== 0}\n onHandlerStateChange={this.onTapHandlerStateChange}>\n <Animated.View\n pointerEvents={rowState === 0 ? 'auto' : 'box-only'}\n style={[\n {\n transform: [{ translateX: this.transX! }],\n },\n this.props.childrenContainerStyle,\n ]}>\n {children}\n </Animated.View>\n </TapGestureHandler>\n </Animated.View>\n </PanGestureHandler>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n leftActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',\n },\n rightActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',\n },\n});\n"]}
@@ -9,7 +9,8 @@ export default function gestureHandlerRootHOC(Component, containerStyles) {
9
9
  }, /*#__PURE__*/React.createElement(Component, props));
10
10
  }
11
11
 
12
- Wrapper.displayName = `gestureHandlerRootHOC(${Component.displayName || Component.name})`;
12
+ Wrapper.displayName = `gestureHandlerRootHOC(${Component.displayName || Component.name})`; // @ts-ignore - hoistNonReactStatics uses old version of @types/react
13
+
13
14
  hoistNonReactStatics(Wrapper, Component);
14
15
  return Wrapper;
15
16
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["gestureHandlerRootHOC.tsx"],"names":["React","StyleSheet","hoistNonReactStatics","GestureHandlerRootView","gestureHandlerRootHOC","Component","containerStyles","Wrapper","props","styles","container","displayName","name","create","flex"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,QAAiD,cAAjD;AACA,OAAOC,oBAAP,MAAiC,yBAAjC;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AAEA,eAAe,SAASC,qBAAT,CAGbC,SAHa,EAIbC,eAJa,EAKW;AACxB,WAASC,OAAT,CAAiBC,KAAjB,EAA2B;AACzB,wBACE,oBAAC,sBAAD;AAAwB,MAAA,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBJ,eAAnB;AAA/B,oBACE,oBAAC,SAAD,EAAeE,KAAf,CADF,CADF;AAKD;;AAEDD,EAAAA,OAAO,CAACI,WAAR,GAAuB,yBACrBN,SAAS,CAACM,WAAV,IAAyBN,SAAS,CAACO,IACpC,GAFD,CATwB,CAaxB;;AACAV,EAAAA,oBAAoB,CAACK,OAAD,EAAUF,SAAV,CAApB;AAEA,SAAOE,OAAP;AACD;AAED,MAAME,MAAM,GAAGR,UAAU,CAACY,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE;AAAEI,IAAAA,IAAI,EAAE;AAAR;AADoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport GestureHandlerRootView from './GestureHandlerRootView';\n\nexport default function gestureHandlerRootHOC<\n P extends Record<string, unknown>\n>(\n Component: React.ComponentType<P>,\n containerStyles?: StyleProp<ViewStyle>\n): React.ComponentType<P> {\n function Wrapper(props: P) {\n return (\n <GestureHandlerRootView style={[styles.container, containerStyles]}>\n <Component {...props} />\n </GestureHandlerRootView>\n );\n }\n\n Wrapper.displayName = `gestureHandlerRootHOC(${\n Component.displayName || Component.name\n })`;\n\n // @ts-ignore - hoistNonReactStatics uses old version of @types/react\n hoistNonReactStatics(Wrapper, Component);\n\n return Wrapper;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}
@@ -6,6 +6,8 @@ export const longPressHandlerName = 'LongPressGestureHandler';
6
6
  export const LongPressGestureHandler = createHandler({
7
7
  name: longPressHandlerName,
8
8
  allowedProps: [...baseGestureHandlerProps, ...longPressGestureHandlerProps],
9
- config: {}
9
+ config: {
10
+ shouldCancelWhenOutside: true
11
+ }
10
12
  });
11
13
  //# sourceMappingURL=LongPressGestureHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["LongPressGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","longPressGestureHandlerProps","longPressHandlerName","LongPressGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;AAiEP,OAAO,MAAMC,oBAAoB,GAAG,yBAA7B;AAGP;AACA,OAAO,MAAMC,uBAAuB,GAAGJ,aAAa,CAGlD;AACAK,EAAAA,IAAI,EAAEF,oBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,4BAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAHkD,CAA7C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const longPressGestureHandlerProps = [\n 'minDurationMs',\n 'maxDist',\n] as const;\n\nexport type LongPressGestureHandlerEventPayload = {\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n x: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n y: number;\n\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteX` instead of\n * `x` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteY` instead of\n * `y` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Duration of the long press (time since the start of the event), expressed\n * in milliseconds.\n */\n duration: number;\n};\n\nexport interface LongPressGestureConfig {\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on\n * the corresponding view. The default value is 500.\n */\n minDurationMs?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a long press gesture. If the finger travels\n * further than the defined distance and the handler hasn't yet activated, it\n * will fail to recognize the gesture. The default value is 10.\n */\n maxDist?: number;\n}\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,\n LongPressGestureConfig {}\n\nexport const longPressHandlerName = 'LongPressGestureHandler';\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: longPressHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...longPressGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}
1
+ {"version":3,"sources":["LongPressGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","longPressGestureHandlerProps","longPressHandlerName","LongPressGestureHandler","name","allowedProps","config","shouldCancelWhenOutside"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;AAiEP,OAAO,MAAMC,oBAAoB,GAAG,yBAA7B;AAGP;AACA,OAAO,MAAMC,uBAAuB,GAAGJ,aAAa,CAGlD;AACAK,EAAAA,IAAI,EAAEF,oBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,4BAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAHkD,CAA7C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const longPressGestureHandlerProps = [\n 'minDurationMs',\n 'maxDist',\n] as const;\n\nexport type LongPressGestureHandlerEventPayload = {\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n x: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n y: number;\n\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteX` instead of\n * `x` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteY` instead of\n * `y` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Duration of the long press (time since the start of the event), expressed\n * in milliseconds.\n */\n duration: number;\n};\n\nexport interface LongPressGestureConfig {\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on\n * the corresponding view. The default value is 500.\n */\n minDurationMs?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a long press gesture. If the finger travels\n * further than the defined distance and the handler hasn't yet activated, it\n * will fail to recognize the gesture. The default value is 10.\n */\n maxDist?: number;\n}\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,\n LongPressGestureConfig {}\n\nexport const longPressHandlerName = 'LongPressGestureHandler';\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: longPressHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...longPressGestureHandlerProps,\n ] as const,\n config: {\n shouldCancelWhenOutside: true,\n },\n});\n"]}
@@ -6,6 +6,8 @@ export const tapHandlerName = 'TapGestureHandler';
6
6
  export const TapGestureHandler = createHandler({
7
7
  name: tapHandlerName,
8
8
  allowedProps: [...baseGestureHandlerProps, ...tapGestureHandlerProps],
9
- config: {}
9
+ config: {
10
+ shouldCancelWhenOutside: true
11
+ }
10
12
  });
11
13
  //# sourceMappingURL=TapGestureHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["TapGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","tapGestureHandlerProps","tapHandlerName","TapGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,sBAAsB,GAAG,CACpC,eADoC,EAEpC,YAFoC,EAGpC,cAHoC,EAIpC,WAJoC,EAKpC,WALoC,EAMpC,SANoC,EAOpC,aAPoC,CAA/B;AAuEP,OAAO,MAAMC,cAAc,GAAG,mBAAvB;AAGP;AACA,OAAO,MAAMC,iBAAiB,GAAGJ,aAAa,CAG5C;AACAK,EAAAA,IAAI,EAAEF,cADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,sBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAH4C,CAAvC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const tapGestureHandlerProps = [\n 'maxDurationMs',\n 'maxDelayMs',\n 'numberOfTaps',\n 'maxDeltaX',\n 'maxDeltaY',\n 'maxDist',\n 'minPointers',\n] as const;\n\nexport type TapGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface TapGestureConfig {\n /**\n * Minimum number of pointers (fingers) required to be placed before the\n * handler activates. Should be a positive integer.\n * The default value is 1.\n */\n minPointers?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger\n * must be released after a touch. The default value is 500.\n */\n maxDurationMs?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap\n * if many taps are required. The default value is 500.\n */\n maxDelayMs?: number;\n\n /**\n * Number of tap gestures required to activate the handler. The default value\n * is 1.\n */\n numberOfTaps?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the X axis during a tap gesture. If the finger\n * travels further than the defined distance along the X axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaX?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the Y axis during a tap gesture. If the finger\n * travels further than the defined distance along the Y axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaY?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a tap gesture. If the finger travels further than\n * the defined distance and the handler hasn't yet\n * activated, it will fail to recognize the gesture.\n */\n maxDist?: number;\n}\n\nexport interface TapGestureHandlerProps\n extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,\n TapGestureConfig {}\n\nexport const tapHandlerName = 'TapGestureHandler';\n\nexport type TapGestureHandler = typeof TapGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const TapGestureHandler = createHandler<\n TapGestureHandlerProps,\n TapGestureHandlerEventPayload\n>({\n name: tapHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...tapGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}
1
+ {"version":3,"sources":["TapGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","tapGestureHandlerProps","tapHandlerName","TapGestureHandler","name","allowedProps","config","shouldCancelWhenOutside"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,sBAAsB,GAAG,CACpC,eADoC,EAEpC,YAFoC,EAGpC,cAHoC,EAIpC,WAJoC,EAKpC,WALoC,EAMpC,SANoC,EAOpC,aAPoC,CAA/B;AAuEP,OAAO,MAAMC,cAAc,GAAG,mBAAvB;AAGP;AACA,OAAO,MAAMC,iBAAiB,GAAGJ,aAAa,CAG5C;AACAK,EAAAA,IAAI,EAAEF,cADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,sBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAH4C,CAAvC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const tapGestureHandlerProps = [\n 'maxDurationMs',\n 'maxDelayMs',\n 'numberOfTaps',\n 'maxDeltaX',\n 'maxDeltaY',\n 'maxDist',\n 'minPointers',\n] as const;\n\nexport type TapGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface TapGestureConfig {\n /**\n * Minimum number of pointers (fingers) required to be placed before the\n * handler activates. Should be a positive integer.\n * The default value is 1.\n */\n minPointers?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger\n * must be released after a touch. The default value is 500.\n */\n maxDurationMs?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap\n * if many taps are required. The default value is 500.\n */\n maxDelayMs?: number;\n\n /**\n * Number of tap gestures required to activate the handler. The default value\n * is 1.\n */\n numberOfTaps?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the X axis during a tap gesture. If the finger\n * travels further than the defined distance along the X axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaX?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the Y axis during a tap gesture. If the finger\n * travels further than the defined distance along the Y axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaY?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a tap gesture. If the finger travels further than\n * the defined distance and the handler hasn't yet\n * activated, it will fail to recognize the gesture.\n */\n maxDist?: number;\n}\n\nexport interface TapGestureHandlerProps\n extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,\n TapGestureConfig {}\n\nexport const tapHandlerName = 'TapGestureHandler';\n\nexport type TapGestureHandler = typeof TapGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const TapGestureHandler = createHandler<\n TapGestureHandlerProps,\n TapGestureHandlerEventPayload\n>({\n name: tapHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...tapGestureHandlerProps,\n ] as const,\n config: {\n shouldCancelWhenOutside: true,\n },\n});\n"]}
@@ -13,6 +13,7 @@ import { filterConfig, findNodeHandle, scheduleFlushOperations } from './gesture
13
13
  import { isFabric, isJestEnv, tagMessage } from '../utils';
14
14
  import { ActionType } from '../ActionType';
15
15
  import { PressabilityDebugView } from './PressabilityDebugView';
16
+ import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
16
17
  const UIManagerAny = UIManager;
17
18
  const customGHEventsConfigFabricAndroid = {
18
19
  topOnGestureHandlerEvent: {
@@ -125,12 +126,12 @@ export default function createHandler({
125
126
 
126
127
  _defineProperty(this, "propsRef", void 0);
127
128
 
129
+ _defineProperty(this, "isMountedRef", void 0);
130
+
128
131
  _defineProperty(this, "viewNode", void 0);
129
132
 
130
133
  _defineProperty(this, "viewTag", void 0);
131
134
 
132
- _defineProperty(this, "updateEnqueued", null);
133
-
134
135
  _defineProperty(this, "inspectorToggleListener", void 0);
135
136
 
136
137
  _defineProperty(this, "onGestureHandlerEvent", event => {
@@ -234,6 +235,7 @@ export default function createHandler({
234
235
  this.handlerTag = getNextHandlerTag();
235
236
  this.config = {};
236
237
  this.propsRef = /*#__PURE__*/React.createRef();
238
+ this.isMountedRef = /*#__PURE__*/React.createRef();
237
239
  this.state = {
238
240
  allowTouches
239
241
  };
@@ -249,6 +251,7 @@ export default function createHandler({
249
251
 
250
252
  componentDidMount() {
251
253
  const props = this.props;
254
+ this.isMountedRef.current = true;
252
255
 
253
256
  if (DEV_ON_ANDROID) {
254
257
  this.inspectorToggleListener = DeviceEventEmitter.addListener('toggleElementInspector', () => {
@@ -263,11 +266,10 @@ export default function createHandler({
263
266
  // If there are unresolved refs (e.g. ".current" has not yet been set)
264
267
  // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
265
268
  // _update method that will try to update native handler props using
266
- // setImmediate. This makes it so update() function gets called after all
269
+ // queueMicrotask. This makes it so update() function gets called after all
267
270
  // react components are mounted and we expect the missing ref object to
268
271
  // be resolved by then.
269
- this.updateEnqueued = setImmediate(() => {
270
- this.updateEnqueued = null;
272
+ queueMicrotask(() => {
271
273
  this.update(UNRESOLVED_REFS_RETRY_LIMIT);
272
274
  });
273
275
  }
@@ -290,13 +292,9 @@ export default function createHandler({
290
292
  var _this$inspectorToggle;
291
293
 
292
294
  (_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
295
+ this.isMountedRef.current = false;
293
296
  RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
294
- scheduleFlushOperations();
295
-
296
- if (this.updateEnqueued) {
297
- clearImmediate(this.updateEnqueued);
298
- } // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context
299
-
297
+ scheduleFlushOperations(); // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context
300
298
 
301
299
  const handlerID = this.props.id;
302
300
 
@@ -307,13 +305,16 @@ export default function createHandler({
307
305
  }
308
306
 
309
307
  update(remainingTries) {
308
+ if (!this.isMountedRef.current) {
309
+ return;
310
+ }
311
+
310
312
  const props = this.props; // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
311
313
  // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
312
314
  // again is easy enough fix.
313
315
 
314
316
  if (hasUnresolvedRefs(props) && remainingTries > 0) {
315
- this.updateEnqueued = setImmediate(() => {
316
- this.updateEnqueued = null;
317
+ queueMicrotask(() => {
317
318
  this.update(remainingTries - 1);
318
319
  });
319
320
  } else {
@@ -336,6 +337,10 @@ export default function createHandler({
336
337
  render() {
337
338
  var _this$props$testID;
338
339
 
340
+ if (__DEV__ && !this.context) {
341
+ throw new Error(name + ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
342
+ }
343
+
339
344
  let gestureEventHandler = this.onGestureHandlerEvent; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
340
345
 
341
346
  const {
@@ -420,6 +425,8 @@ export default function createHandler({
420
425
 
421
426
  _defineProperty(Handler, "displayName", name);
422
427
 
428
+ _defineProperty(Handler, "contextType", GestureHandlerRootViewContext);
429
+
423
430
  return Handler;
424
431
  }
425
432
  //# sourceMappingURL=createHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["createHandler.tsx"],"names":["React","Platform","UIManager","DeviceEventEmitter","deepEqual","RNGestureHandlerModule","State","handlerIDToTag","getNextHandlerTag","registerOldGestureHandler","filterConfig","findNodeHandle","scheduleFlushOperations","isFabric","isJestEnv","tagMessage","ActionType","PressabilityDebugView","UIManagerAny","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,SAFF,EAGEC,kBAHF,QAKO,cALP,C,CAMA;;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SACEC,cADF,EAEEC,iBAFF,EAGEC,yBAHF,QAIO,oBAJP;AAMA,SAEEC,YAFF,EAKEC,cALF,EAMEC,uBANF,QAOO,wBAPP;AASA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,UAAhD;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,yBAAtC;AAEA,MAAMC,YAAY,GAAGhB,SAArB;AAEA,MAAMiB,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gB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Aa,GAAG1C,KAAK,CAACpC,KAAN,CAAYuC,QAAhC;;AACA,UACE1C,OAAO,IACPuC,KAAK,CAAC2C,IADN,KAEC3C,KAAK,CAAC2C,IAAN,KAAe,wBAAf,IACC3C,KAAK,CAAC2C,IAAN,CAAW7D,IAAX,KAAoB,MADrB,IAECkB,KAAK,CAAC2C,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAF,QAAAA,aAAa,GAAG1H,KAAK,CAACiF,QAAN,CAAe4C,OAAf,CAAuBH,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACI,IAAd,eACE,oBAAC,qBAAD;AACE,UAAA,GAAG,EAAC,uBADN;AAEE,UAAA,KAAK,EAAC,mBAFR;AAGE,UAAA,OAAO,EAAE9C,KAAK,CAACpC,KAAN,CAAYmF;AAHvB,UADF;AAOD;;AAED,0BAAO/H,KAAK,CAACgI,YAAN,CACLhD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAK6C,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAIpH,SAAS,KACT;AACEqH,UAAAA,WAAW,EAAErE,IADf;AAEEU,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADS,GAKT,EALJ,CAHF;AASE4D,QAAAA,MAAM,wBAAE,KAAKxF,KAAL,CAAWwF,MAAb,mEAAuBpD,KAAK,CAACpC,KAAN,CAAYwF,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AA3VD;;AAPwE,kBAIpEvD,OAJoE,iBAQnDL,IARmD;;AAoW1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<HandlerPropsT extends Record<string, unknown>> =\n Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n }>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\nconst UNRESOLVED_REFS_RETRY_LIMIT = 1;\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update(remainingTries: number) {\n const props: HandlerProps<U> = this.props;\n\n // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of\n // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying\n // again is easy enough fix.\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update(remainingTries - 1);\n });\n } else {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
1
+ {"version":3,"sources":["createHandler.tsx"],"names":["React","Platform","UIManager","DeviceEventEmitter","deepEqual","RNGestureHandlerModule","State","handlerIDToTag","getNextHandlerTag","registerOldGestureHandler","filterConfig","findNodeHandle","scheduleFlushOperations","isFabric","isJestEnv","tagMessage","ActionType","PressabilityDebugView","GestureHandlerRootViewContext","UIManagerAny","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","UNRESOLVED_REFS_RETRY_LIMIT","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","isMountedRef","id","Error","componentDidMount","inspectorToggleListener","setState","_","update","queueMicrotask","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","handlerID","remainingTries","setNativeProps","updates","mergedProps","render","context","gestureEventHandler","gestureStateEventHandler","events","e","grandChildren","type","displayName","toArray","push","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,SAFF,EAGEC,kBAHF,QAKO,cALP,C,CAMA;;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SACEC,cADF,EAEEC,iBAFF,EAGEC,yBAHF,QAIO,oBAJP;AAMA,SAEEC,YAFF,EAKEC,cALF,EAMEC,uBANF,QAOO,wBAPP;AASA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,UAAhD;AACA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AAWwF,MAAb,mEAAuBpD,KAAK,CAACpC,KAAN,CAAYwF,MAT3C;AAUE,WAAGZ;AAVL,OAFK,EAcLE,aAdK,CAAP;AAgBD;;AArWD;;AAPwE,kBAIpEvD,OAJoE,iBAQnDL,IARmD;;AAAA,kBAIpEK,OAJoE,iBASnDlD,6BATmD;;AA8W1E,SAAOkD,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\nimport { PressabilityDebugView } from './PressabilityDebugView';\nimport GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<HandlerPropsT extends Record<string, unknown>> =\n Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n }>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\nconst UNRESOLVED_REFS_RETRY_LIMIT = 1;\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n static contextType = GestureHandlerRootViewContext;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private isMountedRef: React.MutableRefObject<boolean | null>;\n private viewNode: any;\n private viewTag?: number;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.isMountedRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n this.isMountedRef.current = true;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // queueMicrotask. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n queueMicrotask(() => {\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update(UNRESOLVED_REFS_RETRY_LIMIT);\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n this.isMountedRef.current = false;\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (\n RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler\n )(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update(remainingTries: number) {\n if (!this.isMountedRef.current) {\n return;\n }\n\n const props: HandlerProps<U> = this.props;\n\n // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of\n // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying\n // again is easy enough fix.\n if (hasUnresolvedRefs(props) && remainingTries > 0) {\n queueMicrotask(() => {\n this.update(remainingTries - 1);\n });\n } else {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n if (__DEV__ && !this.context) {\n throw new Error(\n name +\n ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'\n );\n }\n\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const { onGestureEvent, onGestureHandlerEvent }: OnGestureEventHandlers =\n this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n let child: any = null;\n try {\n child = React.Children.only(this.props.children);\n } catch (e) {\n throw new Error(\n tagMessage(\n `${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`\n )\n );\n }\n\n let grandChildren = child.props.children;\n if (\n __DEV__ &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n <PressabilityDebugView\n key=\"pressabilityDebugView\"\n color=\"mediumspringgreen\"\n hitSlop={child.props.hitSlop}\n />\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
@@ -67,12 +67,13 @@ export function findNodeHandle(node) {
67
67
 
68
68
  return findNodeHandleRN(node);
69
69
  }
70
- let scheduledFlushOperationsId = null;
70
+ let flushOperationsScheduled = false;
71
71
  export function scheduleFlushOperations() {
72
- if (scheduledFlushOperationsId === null) {
73
- scheduledFlushOperationsId = requestAnimationFrame(() => {
72
+ if (!flushOperationsScheduled) {
73
+ flushOperationsScheduled = true;
74
+ queueMicrotask(() => {
74
75
  RNGestureHandlerModule.flushOperations();
75
- scheduledFlushOperationsId = null;
76
+ flushOperationsScheduled = false;
76
77
  });
77
78
  }
78
79
  }