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
@@ -40,9 +40,4 @@ export default class ManualGestureHandler extends GestureHandler {
40
40
  super.onPointerRemove(event);
41
41
  this.tracker.removeFromTracker(event.pointerId);
42
42
  }
43
-
44
- protected onPointerCancel(event: AdaptedEvent): void {
45
- super.onPointerCancel(event);
46
- this.reset();
47
- }
48
43
  }
@@ -115,12 +115,6 @@ export default class NativeViewGestureHandler extends GestureHandler {
115
115
  }
116
116
  }
117
117
 
118
- protected onPointerCancel(event: AdaptedEvent): void {
119
- super.onPointerCancel(event);
120
- this.cancel();
121
- this.reset();
122
- }
123
-
124
118
  public shouldRecognizeSimultaneously(handler: GestureHandler): boolean {
125
119
  if (super.shouldRecognizeSimultaneously(handler)) {
126
120
  return true;
@@ -1,4 +1,3 @@
1
- import { PixelRatio } from 'react-native';
2
1
  import { State } from '../../State';
3
2
  import { DEFAULT_TOUCH_SLOP } from '../constants';
4
3
  import { AdaptedEvent, Config } from '../interfaces';
@@ -188,7 +187,6 @@ export default class PanGestureHandler extends GestureHandler {
188
187
 
189
188
  protected transformNativeEvent() {
190
189
  const rect: DOMRect = this.view.getBoundingClientRect();
191
- const ratio = PixelRatio.get();
192
190
 
193
191
  const translationX: number = this.getTranslationX();
194
192
  const translationY: number = this.getTranslationY();
@@ -198,8 +196,8 @@ export default class PanGestureHandler extends GestureHandler {
198
196
  translationY: isNaN(translationY) ? 0 : translationY,
199
197
  absoluteX: this.tracker.getLastAvgX(),
200
198
  absoluteY: this.tracker.getLastAvgY(),
201
- velocityX: this.velocityX * ratio * 10,
202
- velocityY: this.velocityY * ratio * 10,
199
+ velocityX: this.velocityX,
200
+ velocityY: this.velocityY,
203
201
  x: this.tracker.getLastAvgX() - rect.left,
204
202
  y: this.tracker.getLastAvgY() - rect.top,
205
203
  };
@@ -306,11 +304,6 @@ export default class PanGestureHandler extends GestureHandler {
306
304
  super.onPointerMove(event);
307
305
  }
308
306
 
309
- protected onPointerCancel(event: AdaptedEvent): void {
310
- super.onPointerCancel(event);
311
-
312
- this.reset();
313
- }
314
307
  protected onPointerOutOfBounds(event: AdaptedEvent): void {
315
308
  if (this.getShouldCancelWhenOutside()) {
316
309
  return;
@@ -127,11 +127,6 @@ export default class PinchGestureHandler extends GestureHandler {
127
127
  super.onPointerOutOfBounds(event);
128
128
  }
129
129
 
130
- protected onPointerCancel(event: AdaptedEvent): void {
131
- super.onPointerCancel(event);
132
- this.reset();
133
- }
134
-
135
130
  private tryBegin(): void {
136
131
  if (this.currentState !== State.UNDETERMINED) {
137
132
  return;
@@ -148,13 +148,6 @@ export default class RotationGestureHandler extends GestureHandler {
148
148
  this.tracker.removeFromTracker(event.pointerId);
149
149
  }
150
150
 
151
- protected onPointerCancel(event: AdaptedEvent): void {
152
- super.onPointerCancel(event);
153
- this.end();
154
-
155
- this.reset();
156
- }
157
-
158
151
  protected tryBegin(): void {
159
152
  if (this.currentState !== State.UNDETERMINED) {
160
153
  return;
@@ -33,7 +33,6 @@ export default class TapGestureHandler extends GestureHandler {
33
33
 
34
34
  public init(ref: number, propsRef: React.RefObject<unknown>): void {
35
35
  super.init(ref, propsRef);
36
- this.setShouldCancelWhenOutside(true);
37
36
  }
38
37
 
39
38
  public updateGestureConfig({ enabled = true, ...props }: Config): void {
@@ -198,12 +197,6 @@ export default class TapGestureHandler extends GestureHandler {
198
197
  super.onPointerOutOfBounds(event);
199
198
  }
200
199
 
201
- protected onPointerCancel(event: AdaptedEvent): void {
202
- super.onPointerCancel(event);
203
- this.tracker.resetTracker();
204
- this.fail();
205
- }
206
-
207
200
  private updateState(event: AdaptedEvent): void {
208
201
  if (
209
202
  this.currentMaxNumberOfPointers < this.tracker.getTrackedPointersCount()
@@ -0,0 +1,42 @@
1
+ export default class CircularBuffer<T> {
2
+ private bufferSize: number;
3
+ private buffer: T[];
4
+ private index: number;
5
+ private actualSize: number;
6
+
7
+ constructor(size: number) {
8
+ this.bufferSize = size;
9
+ this.buffer = new Array<T>(size);
10
+ this.index = 0;
11
+ this.actualSize = 0;
12
+ }
13
+
14
+ public get size(): number {
15
+ return this.actualSize;
16
+ }
17
+
18
+ public push(element: T): void {
19
+ this.buffer[this.index] = element;
20
+ this.index = (this.index + 1) % this.bufferSize;
21
+ this.actualSize = Math.min(this.actualSize + 1, this.bufferSize);
22
+ }
23
+
24
+ public get(at: number): T {
25
+ if (this.actualSize === this.bufferSize) {
26
+ let index = (this.index + at) % this.bufferSize;
27
+ if (index < 0) {
28
+ index += this.bufferSize;
29
+ }
30
+
31
+ return this.buffer[index];
32
+ } else {
33
+ return this.buffer[at];
34
+ }
35
+ }
36
+
37
+ public clear(): void {
38
+ this.buffer = new Array<T>(this.bufferSize);
39
+ this.index = 0;
40
+ this.actualSize = 0;
41
+ }
42
+ }
@@ -0,0 +1,182 @@
1
+ // Implementation taken from Flutter's LeastSquareSolver
2
+ // https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/gestures/lsq_solver.dart
3
+
4
+ class Vector {
5
+ private offset: number;
6
+ private length: number;
7
+ private elements: number[];
8
+
9
+ constructor(length: number) {
10
+ this.offset = 0;
11
+ this.length = length;
12
+ this.elements = new Array<number>(length);
13
+ }
14
+
15
+ public static fromVOL(
16
+ values: number[],
17
+ offset: number,
18
+ length: number
19
+ ): Vector {
20
+ const result = new Vector(0);
21
+
22
+ result.offset = offset;
23
+ result.length = length;
24
+ result.elements = values;
25
+
26
+ return result;
27
+ }
28
+
29
+ public get(index: number): number {
30
+ return this.elements[this.offset + index];
31
+ }
32
+
33
+ public set(index: number, value: number): void {
34
+ this.elements[this.offset + index] = value;
35
+ }
36
+
37
+ public dot(other: Vector): number {
38
+ let result = 0;
39
+ for (let i = 0; i < this.length; i++) {
40
+ result += this.get(i) * other.get(i);
41
+ }
42
+ return result;
43
+ }
44
+
45
+ public norm() {
46
+ return Math.sqrt(this.dot(this));
47
+ }
48
+ }
49
+
50
+ class Matrix {
51
+ private columns: number;
52
+ private elements: number[];
53
+
54
+ constructor(rows: number, columns: number) {
55
+ this.columns = columns;
56
+ this.elements = new Array<number>(rows * columns);
57
+ }
58
+
59
+ public get(row: number, column: number): number {
60
+ return this.elements[row * this.columns + column];
61
+ }
62
+
63
+ public set(row: number, column: number, value: number): void {
64
+ this.elements[row * this.columns + column] = value;
65
+ }
66
+
67
+ public getRow(row: number): Vector {
68
+ return Vector.fromVOL(this.elements, row * this.columns, this.columns);
69
+ }
70
+ }
71
+
72
+ /// An nth degree polynomial fit to a dataset.
73
+ class PolynomialFit {
74
+ /// The polynomial coefficients of the fit.
75
+ ///
76
+ /// For each `i`, the element `coefficients[i]` is the coefficient of
77
+ /// the `i`-th power of the variable.
78
+ public coefficients: number[];
79
+
80
+ /// Creates a polynomial fit of the given degree.
81
+ ///
82
+ /// There are n + 1 coefficients in a fit of degree n.
83
+ constructor(degree: number) {
84
+ this.coefficients = new Array<number>(degree + 1);
85
+ }
86
+ }
87
+
88
+ const precisionErrorTolerance = 1e-10;
89
+
90
+ /// Uses the least-squares algorithm to fit a polynomial to a set of data.
91
+ export default class LeastSquareSolver {
92
+ /// The x-coordinates of each data point.
93
+ private x: number[];
94
+ /// The y-coordinates of each data point.
95
+ private y: number[];
96
+ /// The weight to use for each data point.
97
+ private w: number[];
98
+
99
+ /// Creates a least-squares solver.
100
+ ///
101
+ /// The [x], [y], and [w] arguments must not be null.
102
+ constructor(x: number[], y: number[], w: number[]) {
103
+ this.x = x;
104
+ this.y = y;
105
+ this.w = w;
106
+ }
107
+
108
+ /// Fits a polynomial of the given degree to the data points.
109
+ ///
110
+ /// When there is not enough data to fit a curve null is returned.
111
+ public solve(degree: number): PolynomialFit | null {
112
+ if (degree > this.x.length) {
113
+ // Not enough data to fit a curve.
114
+ return null;
115
+ }
116
+
117
+ const result = new PolynomialFit(degree);
118
+
119
+ // Shorthands for the purpose of notation equivalence to original C++ code.
120
+ const m = this.x.length;
121
+ const n = degree + 1;
122
+
123
+ // Expand the X vector to a matrix A, pre-multiplied by the weights.
124
+ const a = new Matrix(n, m);
125
+ for (let h = 0; h < m; h++) {
126
+ a.set(0, h, this.w[h]);
127
+
128
+ for (let i = 1; i < n; i++) {
129
+ a.set(i, h, a.get(i - 1, h) * this.x[h]);
130
+ }
131
+ }
132
+
133
+ // Apply the Gram-Schmidt process to A to obtain its QR decomposition.
134
+
135
+ // Orthonormal basis, column-major ordVectorer.
136
+ const q = new Matrix(n, m);
137
+ // Upper triangular matrix, row-major order.
138
+ const r = new Matrix(n, m);
139
+
140
+ for (let j = 0; j < n; j += 1) {
141
+ for (let h = 0; h < m; h += 1) {
142
+ q.set(j, h, a.get(j, h));
143
+ }
144
+ for (let i = 0; i < j; i += 1) {
145
+ const dot = q.getRow(j).dot(q.getRow(i));
146
+ for (let h = 0; h < m; h += 1) {
147
+ q.set(j, h, q.get(j, h) - dot * q.get(i, h));
148
+ }
149
+ }
150
+
151
+ const norm = q.getRow(j).norm();
152
+ if (norm < precisionErrorTolerance) {
153
+ // Vectors are linearly dependent or zero so no solution.
154
+ return null;
155
+ }
156
+
157
+ const inverseNorm = 1.0 / norm;
158
+ for (let h = 0; h < m; h += 1) {
159
+ q.set(j, h, q.get(j, h) * inverseNorm);
160
+ }
161
+ for (let i = 0; i < n; i += 1) {
162
+ r.set(j, i, i < j ? 0.0 : q.getRow(j).dot(a.getRow(i)));
163
+ }
164
+ }
165
+
166
+ // Solve R B = Qt W Y to find B. This is easy because R is upper triangular.
167
+ // We just work from bottom-right to top-left calculating B's coefficients.
168
+ const wy = new Vector(m);
169
+ for (let h = 0; h < m; h += 1) {
170
+ wy.set(h, this.y[h] * this.w[h]);
171
+ }
172
+ for (let i = n - 1; i >= 0; i -= 1) {
173
+ result.coefficients[i] = q.getRow(i).dot(wy);
174
+ for (let j = n - 1; j > i; j -= 1) {
175
+ result.coefficients[i] -= r.get(i, j) * result.coefficients[j];
176
+ }
177
+ result.coefficients[i] /= r.get(i, i);
178
+ }
179
+
180
+ return result;
181
+ }
182
+ }
@@ -8,6 +8,8 @@ import EventManager from './EventManager';
8
8
  import { isPointerInBounds } from '../utils';
9
9
 
10
10
  export default class PointerEventManager extends EventManager {
11
+ private trackedPointers = new Set<number>();
12
+
11
13
  public setListeners(): void {
12
14
  this.view.addEventListener('pointerdown', (event: PointerEvent): void => {
13
15
  if (event.pointerType === PointerType.TOUCH) {
@@ -24,6 +26,7 @@ export default class PointerEventManager extends EventManager {
24
26
 
25
27
  target.setPointerCapture(adaptedEvent.pointerId);
26
28
  this.markAsInBounds(adaptedEvent.pointerId);
29
+ this.trackedPointers.add(adaptedEvent.pointerId);
27
30
 
28
31
  if (++this.activePointersCounter > 1) {
29
32
  adaptedEvent.eventType = EventTypes.ADDITIONAL_POINTER_DOWN;
@@ -51,6 +54,7 @@ export default class PointerEventManager extends EventManager {
51
54
 
52
55
  target.releasePointerCapture(adaptedEvent.pointerId);
53
56
  this.markAsOutOfBounds(adaptedEvent.pointerId);
57
+ this.trackedPointers.delete(adaptedEvent.pointerId);
54
58
 
55
59
  if (--this.activePointersCounter > 0) {
56
60
  adaptedEvent.eventType = EventTypes.ADDITIONAL_POINTER_UP;
@@ -115,7 +119,27 @@ export default class PointerEventManager extends EventManager {
115
119
  this.onPointerCancel(adaptedEvent);
116
120
  this.markAsOutOfBounds(adaptedEvent.pointerId);
117
121
  this.activePointersCounter = 0;
122
+ this.trackedPointers.clear();
118
123
  });
124
+
125
+ this.view.addEventListener(
126
+ 'lostpointercapture',
127
+ (event: PointerEvent): void => {
128
+ const adaptedEvent: AdaptedEvent = this.mapEvent(
129
+ event,
130
+ EventTypes.CANCEL
131
+ );
132
+
133
+ if (this.trackedPointers.has(adaptedEvent.pointerId)) {
134
+ // in some cases the `pointerup` event is not fired, but `lostpointercapture` is
135
+ // we simulate the `pointercancel` event here to make sure the gesture handler stops tracking it
136
+ this.onPointerCancel(adaptedEvent);
137
+
138
+ this.activePointersCounter = 0;
139
+ this.trackedPointers.clear();
140
+ }
141
+ }
142
+ );
119
143
  }
120
144
 
121
145
  protected mapEvent(event: PointerEvent, eventType: EventTypes): AdaptedEvent {
@@ -131,4 +155,9 @@ export default class PointerEventManager extends EventManager {
131
155
  time: event.timeStamp,
132
156
  };
133
157
  }
158
+
159
+ public resetManager(): void {
160
+ super.resetManager();
161
+ this.trackedPointers.clear();
162
+ }
134
163
  }
@@ -1,4 +1,5 @@
1
1
  import { AdaptedEvent } from '../interfaces';
2
+ import VelocityTracker from './VelocityTracker';
2
3
 
3
4
  export interface TrackerElement {
4
5
  lastX: number;
@@ -10,11 +11,10 @@ export interface TrackerElement {
10
11
  velocityY: number;
11
12
  }
12
13
 
13
- // Used to scale velocity so that it is similar to velocity in Android/iOS
14
- const VELOCITY_FACTOR = 0.2;
15
14
  const MAX_POINTERS = 20;
16
15
 
17
16
  export default class PointerTracker {
17
+ private velocityTracker = new VelocityTracker();
18
18
  private trackedPointers: Map<number, TrackerElement> = new Map<
19
19
  number,
20
20
  TrackerElement
@@ -74,12 +74,11 @@ export default class PointerTracker {
74
74
 
75
75
  this.lastMovedPointerId = event.pointerId;
76
76
 
77
- const dx = event.x - element.lastX;
78
- const dy = event.y - element.lastY;
79
- const dt = event.time - element.timeStamp;
77
+ this.velocityTracker.add(event);
78
+ const [velocityX, velocityY] = this.velocityTracker.getVelocity();
80
79
 
81
- element.velocityX = (dx / dt) * 1000 * VELOCITY_FACTOR;
82
- element.velocityY = (dy / dt) * 1000 * VELOCITY_FACTOR;
80
+ element.velocityX = velocityX;
81
+ element.velocityY = velocityY;
83
82
 
84
83
  element.lastX = event.x;
85
84
  element.lastY = event.y;
@@ -223,6 +222,7 @@ export default class PointerTracker {
223
222
  }
224
223
 
225
224
  public resetTracker(): void {
225
+ this.velocityTracker.reset();
226
226
  this.trackedPointers.clear();
227
227
  this.lastMovedPointerId = NaN;
228
228
 
@@ -0,0 +1,98 @@
1
+ import { AdaptedEvent } from '../interfaces';
2
+ import CircularBuffer from './CircularBuffer';
3
+ import LeastSquareSolver from './LeastSquareSolver';
4
+
5
+ export default class VelocityTracker {
6
+ private assumePointerMoveStoppedMilliseconds = 40;
7
+ private historySize = 20;
8
+ private horizonMilliseconds = 300;
9
+ private minSampleSize = 3;
10
+
11
+ private samples: CircularBuffer<AdaptedEvent>;
12
+
13
+ constructor() {
14
+ this.samples = new CircularBuffer<AdaptedEvent>(this.historySize);
15
+ }
16
+
17
+ public add(event: AdaptedEvent): void {
18
+ this.samples.push(event);
19
+ }
20
+
21
+ /// Returns an estimate of the velocity of the object being tracked by the
22
+ /// tracker given the current information available to the tracker.
23
+ ///
24
+ /// Information is added using [addPosition].
25
+ ///
26
+ /// Returns null if there is no data on which to base an estimate.
27
+ private getVelocityEstimate(): [number, number] | null {
28
+ const x = [];
29
+ const y = [];
30
+ const w = [];
31
+ const time = [];
32
+
33
+ let sampleCount = 0;
34
+ let index = this.samples.size - 1;
35
+ const newestSample = this.samples.get(index);
36
+ if (!newestSample) {
37
+ return null;
38
+ }
39
+
40
+ let previousSample = newestSample;
41
+
42
+ // Starting with the most recent PointAtTime sample, iterate backwards while
43
+ // the samples represent continuous motion.
44
+ while (sampleCount < this.samples.size) {
45
+ const sample = this.samples.get(index);
46
+
47
+ const age = newestSample.time - sample.time;
48
+ const delta = Math.abs(sample.time - previousSample.time);
49
+ previousSample = sample;
50
+
51
+ if (
52
+ age > this.horizonMilliseconds ||
53
+ delta > this.assumePointerMoveStoppedMilliseconds
54
+ ) {
55
+ break;
56
+ }
57
+
58
+ x.push(sample.x);
59
+ y.push(sample.y);
60
+ w.push(1);
61
+ time.push(-age);
62
+
63
+ sampleCount++;
64
+ index--;
65
+ }
66
+
67
+ if (sampleCount >= this.minSampleSize) {
68
+ const xSolver = new LeastSquareSolver(time, x, w);
69
+ const xFit = xSolver.solve(2);
70
+
71
+ if (xFit !== null) {
72
+ const ySolver = new LeastSquareSolver(time, y, w);
73
+ const yFit = ySolver.solve(2);
74
+
75
+ if (yFit !== null) {
76
+ const xVelocity = xFit.coefficients[1] * 1000;
77
+ const yVelocity = yFit.coefficients[1] * 1000;
78
+
79
+ return [xVelocity, yVelocity];
80
+ }
81
+ }
82
+ }
83
+
84
+ return null;
85
+ }
86
+
87
+ public getVelocity(): [number, number] {
88
+ const estimate = this.getVelocityEstimate();
89
+ if (estimate !== null) {
90
+ return estimate;
91
+ }
92
+ return [0, 0];
93
+ }
94
+
95
+ public reset(): void {
96
+ this.samples.clear();
97
+ }
98
+ }
@@ -508,7 +508,7 @@ abstract class GestureHandler {
508
508
  .filter((v) => v);
509
509
 
510
510
  if (shouldUseTouchEvents !== this.shouldUseTouchEvents(props)) {
511
- requestAnimationFrame(() => {
511
+ queueMicrotask(() => {
512
512
  // if the undelying event API needs to be changed, we need to unmount and mount
513
513
  // the hammer instance again.
514
514
  this.destroy();
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.enableExperimentalWebImplementation = enableExperimentalWebImplementation;
7
- exports.isExperimentalWebImplementationEnabled = isExperimentalWebImplementationEnabled;
8
-
9
- var _reactNative = require("react-native");
10
-
11
- let EXPERIMENTAL_WEB_IMPLEMENTATION = false;
12
- let getWasCalled = false;
13
-
14
- function enableExperimentalWebImplementation(shouldEnable = true) {
15
- if (_reactNative.Platform.OS !== 'web' || EXPERIMENTAL_WEB_IMPLEMENTATION === shouldEnable) {
16
- return;
17
- }
18
-
19
- if (getWasCalled) {
20
- console.error('Some parts of this application have already started using old gesture handler implementation. No changes will be applied. You can try enabling new implementation earlier.');
21
- return;
22
- }
23
-
24
- EXPERIMENTAL_WEB_IMPLEMENTATION = shouldEnable;
25
- }
26
-
27
- function isExperimentalWebImplementationEnabled() {
28
- getWasCalled = true;
29
- return EXPERIMENTAL_WEB_IMPLEMENTATION;
30
- }
31
- //# sourceMappingURL=EnableExperimentalWebImplementation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["EnableExperimentalWebImplementation.ts"],"names":["EXPERIMENTAL_WEB_IMPLEMENTATION","getWasCalled","enableExperimentalWebImplementation","shouldEnable","Platform","OS","console","error","isExperimentalWebImplementationEnabled"],"mappings":";;;;;;;;AAAA;;AAEA,IAAIA,+BAA+B,GAAG,KAAtC;AACA,IAAIC,YAAY,GAAG,KAAnB;;AAEO,SAASC,mCAAT,CAA6CC,YAAY,GAAG,IAA5D,EAAwE;AAC7E,MACEC,sBAASC,EAAT,KAAgB,KAAhB,IACAL,+BAA+B,KAAKG,YAFtC,EAGE;AACA;AACD;;AAED,MAAIF,YAAJ,EAAkB;AAChBK,IAAAA,OAAO,CAACC,KAAR,CACE,4KADF;AAGA;AACD;;AAEDP,EAAAA,+BAA+B,GAAGG,YAAlC;AACD;;AAEM,SAASK,sCAAT,GAA2D;AAChEP,EAAAA,YAAY,GAAG,IAAf;AACA,SAAOD,+BAAP;AACD","sourcesContent":["import { Platform } from 'react-native';\n\nlet EXPERIMENTAL_WEB_IMPLEMENTATION = false;\nlet getWasCalled = false;\n\nexport function enableExperimentalWebImplementation(shouldEnable = true): void {\n if (\n Platform.OS !== 'web' ||\n EXPERIMENTAL_WEB_IMPLEMENTATION === shouldEnable\n ) {\n return;\n }\n\n if (getWasCalled) {\n console.error(\n 'Some parts of this application have already started using old gesture handler implementation. No changes will be applied. You can try enabling new implementation earlier.'\n );\n return;\n }\n\n EXPERIMENTAL_WEB_IMPLEMENTATION = shouldEnable;\n}\n\nexport function isExperimentalWebImplementationEnabled(): boolean {\n getWasCalled = true;\n return EXPERIMENTAL_WEB_IMPLEMENTATION;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;;;;;AALA;AAOA,MAAMA,qCAAqC,GAAG,gDAC1CC,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADlB,GAE1C,yCAAuB,0BAAvB,CAFJ;;AAOe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACA;AAEA,sBAAO,oBAAC,qCAAD,EAA2CA,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\nimport { shouldUseCodegenNativeComponent } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACA;AAEA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <View {...props} />;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["GestureHandlerRootView.web.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <View {...props} />;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["gestureHandlerRootHOC.tsx"],"names":["gestureHandlerRootHOC","Component","containerStyles","Wrapper","props","styles","container","displayName","name","StyleSheet","create","flex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEe,SAASA,qBAAT,CACbC,SADa,EAEbC,eAFa,EAGW;AACxB,WAASC,OAAT,CAAiBC,KAAjB,EAA2B;AACzB,wBACE,oBAAC,+BAAD;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;AAIA,qCAAqBL,OAArB,EAA8BF,SAA9B;AAEA,SAAOE,OAAP;AACD;;AAED,MAAME,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AAAEK,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<P>(\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 hoistNonReactStatics(Wrapper, Component);\n\n return Wrapper;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n"]}
@@ -1,20 +0,0 @@
1
- import { Platform } from 'react-native';
2
- let EXPERIMENTAL_WEB_IMPLEMENTATION = false;
3
- let getWasCalled = false;
4
- export function enableExperimentalWebImplementation(shouldEnable = true) {
5
- if (Platform.OS !== 'web' || EXPERIMENTAL_WEB_IMPLEMENTATION === shouldEnable) {
6
- return;
7
- }
8
-
9
- if (getWasCalled) {
10
- console.error('Some parts of this application have already started using old gesture handler implementation. No changes will be applied. You can try enabling new implementation earlier.');
11
- return;
12
- }
13
-
14
- EXPERIMENTAL_WEB_IMPLEMENTATION = shouldEnable;
15
- }
16
- export function isExperimentalWebImplementationEnabled() {
17
- getWasCalled = true;
18
- return EXPERIMENTAL_WEB_IMPLEMENTATION;
19
- }
20
- //# sourceMappingURL=EnableExperimentalWebImplementation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["EnableExperimentalWebImplementation.ts"],"names":["Platform","EXPERIMENTAL_WEB_IMPLEMENTATION","getWasCalled","enableExperimentalWebImplementation","shouldEnable","OS","console","error","isExperimentalWebImplementationEnabled"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AAEA,IAAIC,+BAA+B,GAAG,KAAtC;AACA,IAAIC,YAAY,GAAG,KAAnB;AAEA,OAAO,SAASC,mCAAT,CAA6CC,YAAY,GAAG,IAA5D,EAAwE;AAC7E,MACEJ,QAAQ,CAACK,EAAT,KAAgB,KAAhB,IACAJ,+BAA+B,KAAKG,YAFtC,EAGE;AACA;AACD;;AAED,MAAIF,YAAJ,EAAkB;AAChBI,IAAAA,OAAO,CAACC,KAAR,CACE,4KADF;AAGA;AACD;;AAEDN,EAAAA,+BAA+B,GAAGG,YAAlC;AACD;AAED,OAAO,SAASI,sCAAT,GAA2D;AAChEN,EAAAA,YAAY,GAAG,IAAf;AACA,SAAOD,+BAAP;AACD","sourcesContent":["import { Platform } from 'react-native';\n\nlet EXPERIMENTAL_WEB_IMPLEMENTATION = false;\nlet getWasCalled = false;\n\nexport function enableExperimentalWebImplementation(shouldEnable = true): void {\n if (\n Platform.OS !== 'web' ||\n EXPERIMENTAL_WEB_IMPLEMENTATION === shouldEnable\n ) {\n return;\n }\n\n if (getWasCalled) {\n console.error(\n 'Some parts of this application have already started using old gesture handler implementation. No changes will be applied. You can try enabling new implementation earlier.'\n );\n return;\n }\n\n EXPERIMENTAL_WEB_IMPLEMENTATION = shouldEnable;\n}\n\nexport function isExperimentalWebImplementationEnabled(): boolean {\n getWasCalled = true;\n return EXPERIMENTAL_WEB_IMPLEMENTATION;\n}\n"]}
@@ -1,14 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- import * as React from 'react';
3
- import { requireNativeComponent } from 'react-native';
4
- import { maybeInitializeFabric } from './init';
5
- import { shouldUseCodegenNativeComponent } from './utils';
6
- const GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent() ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default : requireNativeComponent('RNGestureHandlerRootView');
7
- export default function GestureHandlerRootView(props) {
8
- // try initialize fabric on the first render, at this point we can
9
- // reliably check if fabric is enabled (the function contains a flag
10
- // to make sure it's called only once)
11
- maybeInitializeFabric();
12
- return /*#__PURE__*/React.createElement(GestureHandlerRootViewNativeComponent, props);
13
- }
14
- //# sourceMappingURL=GestureHandlerRootView.android.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["React","requireNativeComponent","maybeInitializeFabric","shouldUseCodegenNativeComponent","GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":"AAAA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,sBAAT,QAAkD,cAAlD;AACA,SAASC,qBAAT,QAAsC,QAAtC;AACA,SAASC,+BAAT,QAAgD,SAAhD;AAEA,MAAMC,qCAAqC,GAAGD,+BAA+B,KACzEE,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADa,GAEzEL,sBAAsB,CAAC,0BAAD,CAF1B;AAOA,eAAe,SAASM,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACAN,EAAAA,qBAAqB;AAErB,sBAAO,oBAAC,qCAAD,EAA2CM,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\nimport { shouldUseCodegenNativeComponent } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["React","View","maybeInitializeFabric","GestureHandlerRootView","props"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,IAAT,QAAgC,cAAhC;AACA,SAASC,qBAAT,QAAsC,QAAtC;AAKA,eAAe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACAF,EAAAA,qBAAqB;AAErB,sBAAO,oBAAC,IAAD,EAAUE,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <View {...props} />;\n}\n"]}
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { View } from 'react-native';
3
- export default function GestureHandlerRootView(props) {
4
- return /*#__PURE__*/React.createElement(View, props);
5
- }
6
- //# sourceMappingURL=GestureHandlerRootView.web.js.map