react-native-gesture-handler 2.22.1 → 2.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/RNGestureHandler.podspec +8 -0
  2. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +14 -0
  3. package/android/src/main/jni/cpp-adapter.cpp +19 -12
  4. package/apple/RNGestureHandler.mm +15 -8
  5. package/apple/RNGestureHandlerButton.mm +12 -2
  6. package/apple/RNGestureHandlerModule.mm +17 -5
  7. package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
  8. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  9. package/lib/commonjs/components/DrawerLayout.js +6 -0
  10. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  11. package/lib/commonjs/components/GestureButtons.js +11 -2
  12. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  13. package/lib/commonjs/components/Pressable/Pressable.js +21 -5
  14. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  15. package/lib/commonjs/components/Pressable/index.js.map +1 -1
  16. package/lib/commonjs/components/ReanimatedSwipeable.js +49 -20
  17. package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
  18. package/lib/commonjs/components/Text.js +10 -4
  19. package/lib/commonjs/components/Text.js.map +1 -1
  20. package/lib/commonjs/components/touchables/TouchableHighlight.js +2 -0
  21. package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -1
  22. package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +2 -0
  23. package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  24. package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +5 -1
  25. package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -1
  26. package/lib/commonjs/components/touchables/TouchableOpacity.js +2 -0
  27. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  28. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +3 -0
  29. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
  30. package/lib/commonjs/findNodeHandle.web.js +9 -1
  31. package/lib/commonjs/findNodeHandle.web.js.map +1 -1
  32. package/lib/commonjs/handlers/FlingGestureHandler.js +8 -0
  33. package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
  34. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +5 -1
  35. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
  36. package/lib/commonjs/handlers/LongPressGestureHandler.js +8 -0
  37. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  38. package/lib/commonjs/handlers/NativeViewGestureHandler.js +8 -0
  39. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
  40. package/lib/commonjs/handlers/PanGestureHandler.js +8 -0
  41. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
  42. package/lib/commonjs/handlers/PinchGestureHandler.js +8 -0
  43. package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
  44. package/lib/commonjs/handlers/RotationGestureHandler.js +8 -0
  45. package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
  46. package/lib/commonjs/handlers/TapGestureHandler.js +8 -0
  47. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  48. package/lib/commonjs/handlers/createHandler.js +6 -2
  49. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  50. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
  51. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  52. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +2 -2
  53. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  54. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +1 -1
  55. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
  56. package/lib/commonjs/handlers/handlersRegistry.js +7 -2
  57. package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/utils.js +3 -3
  60. package/lib/commonjs/utils.js.map +1 -1
  61. package/lib/commonjs/web/detectors/RotationGestureDetector.js +22 -22
  62. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  63. package/lib/commonjs/web/detectors/ScaleGestureDetector.js +24 -24
  64. package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
  65. package/lib/commonjs/web/handlers/FlingGestureHandler.js +6 -6
  66. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  67. package/lib/commonjs/web/handlers/GestureHandler.js +112 -92
  68. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  69. package/lib/commonjs/web/handlers/HoverGestureHandler.js +2 -2
  70. package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
  71. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +6 -6
  72. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  73. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +13 -13
  74. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  75. package/lib/commonjs/web/handlers/PanGestureHandler.js +15 -15
  76. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  77. package/lib/commonjs/web/handlers/PinchGestureHandler.js +15 -15
  78. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  79. package/lib/commonjs/web/handlers/RotationGestureHandler.js +12 -12
  80. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  81. package/lib/commonjs/web/handlers/TapGestureHandler.js +4 -4
  82. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  83. package/lib/commonjs/web/tools/CircularBuffer.js +15 -15
  84. package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -1
  85. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +40 -40
  86. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  87. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +32 -13
  88. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  89. package/lib/commonjs/web/tools/InteractionManager.js +16 -18
  90. package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
  91. package/lib/commonjs/web/tools/NodeManager.js +2 -2
  92. package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
  93. package/lib/commonjs/web/tools/PointerTracker.js +18 -18
  94. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  95. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  96. package/lib/commonjs/web/tools/VelocityTracker.js +1 -1
  97. package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -1
  98. package/lib/module/RNGestureHandlerModule.web.js +2 -2
  99. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  100. package/lib/module/components/DrawerLayout.js +7 -0
  101. package/lib/module/components/DrawerLayout.js.map +1 -1
  102. package/lib/module/components/GestureButtons.js +10 -2
  103. package/lib/module/components/GestureButtons.js.map +1 -1
  104. package/lib/module/components/Pressable/Pressable.js +22 -6
  105. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  106. package/lib/module/components/Pressable/index.js.map +1 -1
  107. package/lib/module/components/ReanimatedSwipeable.js +49 -20
  108. package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
  109. package/lib/module/components/Text.js +8 -3
  110. package/lib/module/components/Text.js.map +1 -1
  111. package/lib/module/components/touchables/TouchableHighlight.js +2 -0
  112. package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
  113. package/lib/module/components/touchables/TouchableNativeFeedback.android.js +2 -0
  114. package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  115. package/lib/module/components/touchables/TouchableNativeFeedback.js +6 -1
  116. package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -1
  117. package/lib/module/components/touchables/TouchableOpacity.js +5 -0
  118. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  119. package/lib/module/components/touchables/TouchableWithoutFeedback.js +4 -0
  120. package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
  121. package/lib/module/findNodeHandle.web.js +8 -1
  122. package/lib/module/findNodeHandle.web.js.map +1 -1
  123. package/lib/module/handlers/FlingGestureHandler.js +7 -0
  124. package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
  125. package/lib/module/handlers/ForceTouchGestureHandler.js +5 -1
  126. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
  127. package/lib/module/handlers/LongPressGestureHandler.js +7 -0
  128. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  129. package/lib/module/handlers/NativeViewGestureHandler.js +7 -0
  130. package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
  131. package/lib/module/handlers/PanGestureHandler.js +7 -0
  132. package/lib/module/handlers/PanGestureHandler.js.map +1 -1
  133. package/lib/module/handlers/PinchGestureHandler.js +11 -0
  134. package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
  135. package/lib/module/handlers/RotationGestureHandler.js +11 -0
  136. package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
  137. package/lib/module/handlers/TapGestureHandler.js +7 -0
  138. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  139. package/lib/module/handlers/createHandler.js +9 -4
  140. package/lib/module/handlers/createHandler.js.map +1 -1
  141. package/lib/module/handlers/gestures/GestureDetector/index.js +2 -2
  142. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  143. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +2 -2
  144. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  145. package/lib/module/handlers/gestures/GestureDetector/utils.js +2 -2
  146. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
  147. package/lib/module/handlers/handlersRegistry.js +6 -3
  148. package/lib/module/handlers/handlersRegistry.js.map +1 -1
  149. package/lib/module/index.js.map +1 -1
  150. package/lib/module/utils.js +2 -2
  151. package/lib/module/utils.js.map +1 -1
  152. package/lib/module/web/detectors/RotationGestureDetector.js +22 -22
  153. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  154. package/lib/module/web/detectors/ScaleGestureDetector.js +24 -24
  155. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  156. package/lib/module/web/handlers/FlingGestureHandler.js +6 -6
  157. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  158. package/lib/module/web/handlers/GestureHandler.js +112 -92
  159. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  160. package/lib/module/web/handlers/HoverGestureHandler.js +2 -2
  161. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  162. package/lib/module/web/handlers/LongPressGestureHandler.js +6 -6
  163. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  164. package/lib/module/web/handlers/NativeViewGestureHandler.js +13 -13
  165. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/PanGestureHandler.js +15 -15
  167. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/PinchGestureHandler.js +15 -15
  169. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/RotationGestureHandler.js +12 -12
  171. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  172. package/lib/module/web/handlers/TapGestureHandler.js +4 -4
  173. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  174. package/lib/module/web/tools/CircularBuffer.js +15 -15
  175. package/lib/module/web/tools/CircularBuffer.js.map +1 -1
  176. package/lib/module/web/tools/GestureHandlerOrchestrator.js +40 -40
  177. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  178. package/lib/module/web/tools/GestureHandlerWebDelegate.js +32 -13
  179. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  180. package/lib/module/web/tools/InteractionManager.js +16 -16
  181. package/lib/module/web/tools/InteractionManager.js.map +1 -1
  182. package/lib/module/web/tools/NodeManager.js +2 -2
  183. package/lib/module/web/tools/NodeManager.js.map +1 -1
  184. package/lib/module/web/tools/PointerTracker.js +18 -18
  185. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  186. package/lib/module/web/tools/Vector.js.map +1 -1
  187. package/lib/module/web/tools/VelocityTracker.js +1 -1
  188. package/lib/module/web/tools/VelocityTracker.js.map +1 -1
  189. package/lib/typescript/components/DrawerLayout.d.ts +27 -0
  190. package/lib/typescript/components/GestureButtonsProps.d.ts +18 -2
  191. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -10
  192. package/lib/typescript/components/Pressable/index.d.ts +1 -1
  193. package/lib/typescript/components/ReanimatedSwipeable.d.ts +6 -0
  194. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +5 -0
  195. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +2 -0
  196. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +5 -1
  197. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +3 -0
  198. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -0
  199. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +6 -0
  200. package/lib/typescript/handlers/FlingGestureHandler.d.ts +9 -0
  201. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +9 -0
  202. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +9 -0
  203. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +9 -0
  204. package/lib/typescript/handlers/PanGestureHandler.d.ts +9 -0
  205. package/lib/typescript/handlers/PinchGestureHandler.d.ts +9 -0
  206. package/lib/typescript/handlers/RotationGestureHandler.d.ts +9 -0
  207. package/lib/typescript/handlers/TapGestureHandler.d.ts +9 -0
  208. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  209. package/lib/typescript/index.d.ts +1 -1
  210. package/lib/typescript/utils.d.ts +1 -1
  211. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +7 -7
  212. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +8 -8
  213. package/lib/typescript/web/handlers/GestureHandler.d.ts +33 -28
  214. package/lib/typescript/web/handlers/IGestureHandler.d.ts +12 -13
  215. package/lib/typescript/web/tools/CircularBuffer.d.ts +3 -3
  216. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -1
  217. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +2 -2
  218. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +3 -2
  219. package/lib/typescript/web/tools/InteractionManager.d.ts +2 -2
  220. package/lib/typescript/web/tools/NodeManager.d.ts +1 -1
  221. package/lib/typescript/web/tools/PointerTracker.d.ts +4 -4
  222. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -1
  223. package/package.json +2 -2
  224. package/src/RNGestureHandlerModule.web.ts +2 -2
  225. package/src/components/DrawerLayout.tsx +29 -0
  226. package/src/components/GestureButtons.tsx +13 -2
  227. package/src/components/GestureButtonsProps.ts +31 -2
  228. package/src/components/Pressable/Pressable.tsx +22 -5
  229. package/src/components/Pressable/PressableProps.tsx +4 -11
  230. package/src/components/Pressable/index.ts +4 -1
  231. package/src/components/ReanimatedSwipeable.tsx +97 -66
  232. package/src/components/Text.tsx +13 -4
  233. package/src/components/touchables/TouchableHighlight.tsx +5 -0
  234. package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -0
  235. package/src/components/touchables/TouchableNativeFeedback.tsx +6 -1
  236. package/src/components/touchables/TouchableNativeFeedbackProps.tsx +3 -0
  237. package/src/components/touchables/TouchableOpacity.tsx +5 -0
  238. package/src/components/touchables/TouchableWithoutFeedback.tsx +6 -0
  239. package/src/findNodeHandle.web.ts +6 -0
  240. package/src/handlers/FlingGestureHandler.ts +10 -0
  241. package/src/handlers/ForceTouchGestureHandler.ts +9 -0
  242. package/src/handlers/LongPressGestureHandler.ts +10 -0
  243. package/src/handlers/NativeViewGestureHandler.ts +10 -0
  244. package/src/handlers/PanGestureHandler.ts +10 -0
  245. package/src/handlers/PinchGestureHandler.ts +10 -0
  246. package/src/handlers/RotationGestureHandler.ts +10 -0
  247. package/src/handlers/TapGestureHandler.ts +10 -0
  248. package/src/handlers/createHandler.tsx +11 -4
  249. package/src/handlers/gestures/GestureDetector/index.tsx +2 -2
  250. package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +3 -3
  251. package/src/handlers/gestures/GestureDetector/utils.ts +2 -2
  252. package/src/handlers/handlersRegistry.ts +7 -3
  253. package/src/index.ts +4 -1
  254. package/src/utils.ts +2 -2
  255. package/src/web/detectors/RotationGestureDetector.ts +22 -22
  256. package/src/web/detectors/ScaleGestureDetector.ts +24 -24
  257. package/src/web/handlers/FlingGestureHandler.ts +6 -7
  258. package/src/web/handlers/GestureHandler.ts +115 -105
  259. package/src/web/handlers/HoverGestureHandler.ts +2 -2
  260. package/src/web/handlers/IGestureHandler.ts +12 -13
  261. package/src/web/handlers/LongPressGestureHandler.ts +7 -7
  262. package/src/web/handlers/NativeViewGestureHandler.ts +14 -19
  263. package/src/web/handlers/PanGestureHandler.ts +17 -17
  264. package/src/web/handlers/PinchGestureHandler.ts +17 -21
  265. package/src/web/handlers/RotationGestureHandler.ts +12 -12
  266. package/src/web/handlers/TapGestureHandler.ts +4 -6
  267. package/src/web/tools/CircularBuffer.ts +15 -15
  268. package/src/web/tools/GestureHandlerDelegate.ts +1 -1
  269. package/src/web/tools/GestureHandlerOrchestrator.ts +42 -42
  270. package/src/web/tools/GestureHandlerWebDelegate.ts +32 -13
  271. package/src/web/tools/InteractionManager.ts +16 -16
  272. package/src/web/tools/NodeManager.ts +2 -2
  273. package/src/web/tools/PointerTracker.ts +20 -20
  274. package/src/web/tools/Vector.ts +1 -1
  275. package/src/web/tools/VelocityTracker.ts +1 -1
@@ -5,12 +5,22 @@ import {
5
5
  baseGestureHandlerProps,
6
6
  } from './gestureHandlerCommon';
7
7
 
8
+ /**
9
+ * @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
10
+ */
8
11
  export interface PinchGestureHandlerProps
9
12
  extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}
10
13
 
11
14
  export const pinchHandlerName = 'PinchGestureHandler';
12
15
 
16
+ /**
17
+ * @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
18
+ */
13
19
  export type PinchGestureHandler = typeof PinchGestureHandler;
20
+
21
+ /**
22
+ * @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
23
+ */
14
24
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
15
25
  export const PinchGestureHandler = createHandler<
16
26
  PinchGestureHandlerProps,
@@ -5,12 +5,22 @@ import {
5
5
  baseGestureHandlerProps,
6
6
  } from './gestureHandlerCommon';
7
7
 
8
+ /**
9
+ * @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
10
+ */
8
11
  export interface RotationGestureHandlerProps
9
12
  extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}
10
13
 
11
14
  export const rotationHandlerName = 'RotationGestureHandler';
12
15
 
16
+ /**
17
+ * @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
18
+ */
13
19
  export type RotationGestureHandler = typeof RotationGestureHandler;
20
+
21
+ /**
22
+ * @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
23
+ */
14
24
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
15
25
  export const RotationGestureHandler = createHandler<
16
26
  RotationGestureHandlerProps,
@@ -66,13 +66,23 @@ export interface TapGestureConfig {
66
66
  maxDist?: number;
67
67
  }
68
68
 
69
+ /**
70
+ * @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
71
+ */
69
72
  export interface TapGestureHandlerProps
70
73
  extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,
71
74
  TapGestureConfig {}
72
75
 
73
76
  export const tapHandlerName = 'TapGestureHandler';
74
77
 
78
+ /**
79
+ * @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
80
+ */
75
81
  export type TapGestureHandler = typeof TapGestureHandler;
82
+
83
+ /**
84
+ * @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
85
+ */
76
86
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
77
87
  export const TapGestureHandler = createHandler<
78
88
  TapGestureHandlerProps,
@@ -8,7 +8,11 @@ import {
8
8
  import { customDirectEventTypes } from './customDirectEventTypes';
9
9
  import RNGestureHandlerModule from '../RNGestureHandlerModule';
10
10
  import { State } from '../State';
11
- import { handlerIDToTag, registerOldGestureHandler } from './handlersRegistry';
11
+ import {
12
+ handlerIDToTag,
13
+ registerOldGestureHandler,
14
+ unregisterOldGestureHandler,
15
+ } from './handlersRegistry';
12
16
  import { getNextHandlerTag } from './getNextHandlerTag';
13
17
 
14
18
  import {
@@ -19,7 +23,7 @@ import {
19
23
  import { filterConfig, scheduleFlushOperations } from './utils';
20
24
  import findNodeHandle from '../findNodeHandle';
21
25
  import { ValueOf } from '../typeUtils';
22
- import { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils';
26
+ import { deepEqual, isFabric, isTestEnv, tagMessage } from '../utils';
23
27
  import { ActionType } from '../ActionType';
24
28
  import { PressabilityDebugView } from './PressabilityDebugView';
25
29
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
@@ -255,6 +259,9 @@ export default function createHandler<
255
259
  componentWillUnmount() {
256
260
  this.inspectorToggleListener?.remove();
257
261
  this.isMountedRef.current = false;
262
+ if (Platform.OS !== 'web') {
263
+ unregisterOldGestureHandler(this.handlerTag);
264
+ }
258
265
  RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
259
266
  scheduleFlushOperations();
260
267
  // 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
@@ -428,7 +435,7 @@ export default function createHandler<
428
435
  }
429
436
 
430
437
  render() {
431
- if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {
438
+ if (__DEV__ && !this.context && !isTestEnv() && Platform.OS !== 'web') {
432
439
  throw new Error(
433
440
  name +
434
441
  ' 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.'
@@ -539,7 +546,7 @@ export default function createHandler<
539
546
  {
540
547
  ref: this.refHandler,
541
548
  collapsable: false,
542
- ...(isJestEnv()
549
+ ...(isTestEnv()
543
550
  ? {
544
551
  handlerType: name,
545
552
  handlerTag: this.handlerTag,
@@ -11,7 +11,7 @@ import findNodeHandle from '../../../findNodeHandle';
11
11
  import { GestureType } from '../gesture';
12
12
  import { UserSelect, TouchAction } from '../../gestureHandlerCommon';
13
13
  import { ComposedGesture } from '../gestureComposition';
14
- import { isJestEnv } from '../../../utils';
14
+ import { isTestEnv } from '../../../utils';
15
15
 
16
16
  import GestureHandlerRootViewContext from '../../../GestureHandlerRootViewContext';
17
17
  import { AttachedGestureState, GestureDetectorState } from './types';
@@ -94,7 +94,7 @@ interface GestureDetectorProps {
94
94
  */
95
95
  export const GestureDetector = (props: GestureDetectorProps) => {
96
96
  const rootViewContext = useContext(GestureHandlerRootViewContext);
97
- if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
97
+ if (__DEV__ && !rootViewContext && !isTestEnv() && Platform.OS !== 'web') {
98
98
  throw new Error(
99
99
  'GestureDetector 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.'
100
100
  );
@@ -6,7 +6,7 @@ import React, { useCallback } from 'react';
6
6
  import findNodeHandle from '../../../findNodeHandle';
7
7
 
8
8
  declare const global: {
9
- isFormsStackingContext: (node: unknown) => boolean | null; // JSI function
9
+ isViewFlatteningDisabled: (node: unknown) => boolean | null; // JSI function
10
10
  };
11
11
 
12
12
  // Ref handler for the Wrap component attached under the GestureDetector.
@@ -35,9 +35,9 @@ export function useViewRefHandler(
35
35
  updateAttachedGestures(true);
36
36
  }
37
37
 
38
- if (__DEV__ && isFabric() && global.isFormsStackingContext) {
38
+ if (__DEV__ && isFabric() && global.isViewFlatteningDisabled) {
39
39
  const node = getShadowNodeFromRef(ref);
40
- if (global.isFormsStackingContext(node) === false) {
40
+ if (global.isViewFlatteningDisabled(node) === false) {
41
41
  console.error(
42
42
  tagMessage(
43
43
  'GestureDetector has received a child that may get view-flattened. ' +
@@ -1,6 +1,6 @@
1
1
  import { Platform } from 'react-native';
2
2
 
3
- import { isJestEnv, tagMessage } from '../../../utils';
3
+ import { isTestEnv, tagMessage } from '../../../utils';
4
4
  import { GestureRef, BaseGesture, GestureType } from '../gesture';
5
5
 
6
6
  import { flingGestureHandlerProps } from '../../FlingGestureHandler';
@@ -100,7 +100,7 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
100
100
  const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;
101
101
  // If none of the callbacks are worklets and the gesture is not explicitly marked with
102
102
  // `.runOnJS(true)` show a warning
103
- if (areAllNotWorklets && !isJestEnv()) {
103
+ if (areAllNotWorklets && !isTestEnv()) {
104
104
  console.warn(
105
105
  tagMessage(
106
106
  `None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`
@@ -1,4 +1,4 @@
1
- import { isJestEnv } from '../utils';
1
+ import { isTestEnv } from '../utils';
2
2
  import { GestureType } from './gestures/gesture';
3
3
  import { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';
4
4
 
@@ -13,7 +13,7 @@ export function registerHandler(
13
13
  testID?: string
14
14
  ) {
15
15
  gestures.set(handlerTag, handler);
16
- if (isJestEnv() && testID) {
16
+ if (isTestEnv() && testID) {
17
17
  testIDs.set(testID, handlerTag);
18
18
  }
19
19
  }
@@ -25,9 +25,13 @@ export function registerOldGestureHandler(
25
25
  oldHandlers.set(handlerTag, handler);
26
26
  }
27
27
 
28
+ export function unregisterOldGestureHandler(handlerTag: number) {
29
+ oldHandlers.delete(handlerTag);
30
+ }
31
+
28
32
  export function unregisterHandler(handlerTag: number, testID?: string) {
29
33
  gestures.delete(handlerTag);
30
- if (isJestEnv() && testID) {
34
+ if (isTestEnv() && testID) {
31
35
  testIDs.delete(testID);
32
36
  }
33
37
  }
package/src/index.ts CHANGED
@@ -145,7 +145,10 @@ export type {
145
145
 
146
146
  export type { SwipeableProps } from './components/Swipeable';
147
147
  export { default as Swipeable } from './components/Swipeable';
148
- export type { PressableProps } from './components/Pressable';
148
+ export type {
149
+ PressableProps,
150
+ PressableStateCallbackType,
151
+ } from './components/Pressable';
149
152
  export { default as Pressable } from './components/Pressable';
150
153
 
151
154
  export type {
package/src/utils.ts CHANGED
@@ -34,9 +34,9 @@ export function hasProperty(object: object, key: string) {
34
34
  return Object.prototype.hasOwnProperty.call(object, key);
35
35
  }
36
36
 
37
- export function isJestEnv(): boolean {
37
+ export function isTestEnv(): boolean {
38
38
  // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.
39
- return hasProperty(global, 'process') && !!process.env.JEST_WORKER_ID;
39
+ return hasProperty(global, 'process') && process.env.NODE_ENV === 'test';
40
40
  }
41
41
 
42
42
  export function tagMessage(msg: string) {
@@ -18,10 +18,10 @@ export default class RotationGestureDetector
18
18
  private previousTime = 0;
19
19
 
20
20
  private previousAngle = 0;
21
- private rotation = 0;
21
+ private _rotation = 0;
22
22
 
23
- private anchorX = 0;
24
- private anchorY = 0;
23
+ private _anchorX = 0;
24
+ private _anchorY = 0;
25
25
 
26
26
  private isInProgress = false;
27
27
 
@@ -45,28 +45,28 @@ export default class RotationGestureDetector
45
45
  const vectorX: number = secondPointerCoords.x - firstPointerCoords.x;
46
46
  const vectorY: number = secondPointerCoords.y - firstPointerCoords.y;
47
47
 
48
- this.anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;
49
- this.anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2;
48
+ this._anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;
49
+ this._anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2;
50
50
 
51
51
  // Angle diff should be positive when rotating in clockwise direction
52
52
  const angle: number = -Math.atan2(vectorY, vectorX);
53
53
 
54
- this.rotation = Number.isNaN(this.previousAngle)
54
+ this._rotation = Number.isNaN(this.previousAngle)
55
55
  ? 0
56
56
  : this.previousAngle - angle;
57
57
 
58
58
  this.previousAngle = angle;
59
59
 
60
60
  if (this.rotation > Math.PI) {
61
- this.rotation -= Math.PI;
61
+ this._rotation -= Math.PI;
62
62
  } else if (this.rotation < -Math.PI) {
63
- this.rotation += Math.PI;
63
+ this._rotation += Math.PI;
64
64
  }
65
65
 
66
66
  if (this.rotation > Math.PI / 2) {
67
- this.rotation -= Math.PI;
67
+ this._rotation -= Math.PI;
68
68
  } else if (this.rotation < -Math.PI / 2) {
69
- this.rotation += Math.PI;
69
+ this._rotation += Math.PI;
70
70
  }
71
71
  }
72
72
 
@@ -85,7 +85,7 @@ export default class RotationGestureDetector
85
85
  return;
86
86
  }
87
87
 
88
- const pointerIDs: IterableIterator<number> = tracker.getData().keys();
88
+ const pointerIDs: IterableIterator<number> = tracker.trackedPointers.keys();
89
89
 
90
90
  this.keyPointers[0] = pointerIDs.next().value as number;
91
91
  this.keyPointers[1] = pointerIDs.next().value as number;
@@ -143,24 +143,24 @@ export default class RotationGestureDetector
143
143
  return true;
144
144
  }
145
145
 
146
- public getTimeDelta(): number {
147
- return this.currentTime + this.previousTime;
146
+ public reset(): void {
147
+ this.keyPointers = [NaN, NaN];
148
+ this.isInProgress = false;
148
149
  }
149
150
 
150
- public getAnchorX(): number {
151
- return this.anchorX;
151
+ public get anchorX() {
152
+ return this._anchorX;
152
153
  }
153
154
 
154
- public getAnchorY(): number {
155
- return this.anchorY;
155
+ public get anchorY() {
156
+ return this._anchorY;
156
157
  }
157
158
 
158
- public getRotation(): number {
159
- return this.rotation;
159
+ public get rotation() {
160
+ return this._rotation;
160
161
  }
161
162
 
162
- public reset(): void {
163
- this.keyPointers = [NaN, NaN];
164
- this.isInProgress = false;
163
+ public get timeDelta() {
164
+ return this.currentTime + this.previousTime;
165
165
  }
166
166
  }
@@ -14,10 +14,10 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
14
14
  public onScale: (detector: ScaleGestureDetector) => boolean;
15
15
  public onScaleEnd: (detector: ScaleGestureDetector) => void;
16
16
 
17
- private focusX!: number;
18
- private focusY!: number;
17
+ private _focusX!: number;
18
+ private _focusY!: number;
19
19
 
20
- private currentSpan!: number;
20
+ private _currentSpan!: number;
21
21
  private prevSpan!: number;
22
22
  private initialSpan!: number;
23
23
 
@@ -42,7 +42,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
42
42
  this.currentTime = event.time;
43
43
 
44
44
  const action: EventTypes = event.eventType;
45
- const numOfPointers = tracker.getTrackedPointersCount();
45
+ const numOfPointers = tracker.trackedPointersCount;
46
46
 
47
47
  const streamComplete: boolean =
48
48
  action === EventTypes.UP ||
@@ -86,7 +86,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
86
86
  let devSumX = 0;
87
87
  let devSumY = 0;
88
88
 
89
- tracker.getData().forEach((value, key) => {
89
+ tracker.trackedPointers.forEach((value, key) => {
90
90
  if (key === ignoredPointer) {
91
91
  return;
92
92
  }
@@ -105,8 +105,8 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
105
105
 
106
106
  // Begin/end events
107
107
  const wasInProgress: boolean = this.inProgress;
108
- this.focusX = focusX;
109
- this.focusY = focusY;
108
+ this._focusX = focusX;
109
+ this._focusY = focusY;
110
110
 
111
111
  if (this.inProgress && (span < this.minSpan || configChanged)) {
112
112
  this.onScaleEnd(this);
@@ -115,7 +115,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
115
115
  }
116
116
 
117
117
  if (configChanged) {
118
- this.initialSpan = this.prevSpan = this.currentSpan = span;
118
+ this.initialSpan = this.prevSpan = this._currentSpan = span;
119
119
  }
120
120
 
121
121
  if (
@@ -123,7 +123,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
123
123
  span >= this.minSpan &&
124
124
  (wasInProgress || Math.abs(span - this.initialSpan) > this.spanSlop)
125
125
  ) {
126
- this.prevSpan = this.currentSpan = span;
126
+ this.prevSpan = this._currentSpan = span;
127
127
  this.prevTime = this.currentTime;
128
128
  this.inProgress = this.onScaleBegin(this);
129
129
  }
@@ -133,7 +133,7 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
133
133
  return true;
134
134
  }
135
135
 
136
- this.currentSpan = span;
136
+ this._currentSpan = span;
137
137
 
138
138
  if (this.inProgress && !this.onScale(this)) {
139
139
  return true;
@@ -145,27 +145,27 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
145
145
  return true;
146
146
  }
147
147
 
148
- public getCurrentSpan(): number {
149
- return this.currentSpan;
150
- }
148
+ public calculateScaleFactor(numOfPointers: number): number {
149
+ if (numOfPointers < 2) {
150
+ return 1;
151
+ }
151
152
 
152
- public getFocusX(): number {
153
- return this.focusX;
153
+ return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;
154
154
  }
155
155
 
156
- public getFocusY(): number {
157
- return this.focusY;
156
+ public get currentSpan() {
157
+ return this._currentSpan;
158
158
  }
159
159
 
160
- public getTimeDelta(): number {
161
- return this.currentTime - this.prevTime;
160
+ public get focusX() {
161
+ return this._focusX;
162
162
  }
163
163
 
164
- public getScaleFactor(numOfPointers: number): number {
165
- if (numOfPointers < 2) {
166
- return 1;
167
- }
164
+ public get focusY() {
165
+ return this._focusY;
166
+ }
168
167
 
169
- return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;
168
+ public get timeDelta() {
169
+ return this.currentTime - this.prevTime;
170
170
  }
171
171
  }
@@ -121,29 +121,28 @@ export default class FlingGestureHandler extends GestureHandler {
121
121
  }
122
122
 
123
123
  private newPointerAction(): void {
124
- if (this.currentState === State.UNDETERMINED) {
124
+ if (this.state === State.UNDETERMINED) {
125
125
  this.startFling();
126
126
  }
127
127
 
128
- if (this.currentState !== State.BEGAN) {
128
+ if (this.state !== State.BEGAN) {
129
129
  return;
130
130
  }
131
131
 
132
132
  this.tryEndFling();
133
133
 
134
134
  if (
135
- this.tracker.getTrackedPointersCount() >
136
- this.maxNumberOfPointersSimultaneously
135
+ this.tracker.trackedPointersCount > this.maxNumberOfPointersSimultaneously
137
136
  ) {
138
137
  this.maxNumberOfPointersSimultaneously =
139
- this.tracker.getTrackedPointersCount();
138
+ this.tracker.trackedPointersCount;
140
139
  }
141
140
  }
142
141
 
143
142
  private pointerMoveAction(event: AdaptedEvent): void {
144
143
  this.tracker.track(event);
145
144
 
146
- if (this.currentState !== State.BEGAN) {
145
+ if (this.state !== State.BEGAN) {
147
146
  return;
148
147
  }
149
148
 
@@ -173,7 +172,7 @@ export default class FlingGestureHandler extends GestureHandler {
173
172
  }
174
173
 
175
174
  private onUp(event: AdaptedEvent): void {
176
- if (this.currentState === State.BEGAN) {
175
+ if (this.state === State.BEGAN) {
177
176
  this.endFling();
178
177
  }
179
178