react-native-gesture-handler 2.20.2 → 2.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/RNGestureHandler.podspec +9 -0
  2. package/ReanimatedDrawerLayout/package.json +6 -0
  3. package/android/build.gradle +19 -0
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +6 -2
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureDetector.kt +53 -21
  6. package/apple/RNGestureHandlerPointerTracker.m +4 -2
  7. package/lib/commonjs/RNGestureHandlerModule.web.js +15 -2
  8. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  9. package/lib/commonjs/components/Pressable/Pressable.js +2 -6
  10. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  11. package/lib/commonjs/components/ReanimatedDrawerLayout.js +389 -0
  12. package/lib/commonjs/components/ReanimatedDrawerLayout.js.map +1 -0
  13. package/lib/commonjs/components/ReanimatedSwipeable.js +117 -148
  14. package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
  15. package/lib/commonjs/findNodeHandle.js +12 -0
  16. package/lib/commonjs/findNodeHandle.js.map +1 -0
  17. package/lib/commonjs/findNodeHandle.web.js +40 -0
  18. package/lib/commonjs/findNodeHandle.web.js.map +1 -0
  19. package/lib/commonjs/handlers/createHandler.js +4 -2
  20. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  21. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js +51 -0
  22. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
  23. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -1
  24. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  25. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +5 -3
  26. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
  27. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +4 -2
  28. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  29. package/lib/commonjs/web/handlers/GestureHandler.js +4 -0
  30. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  31. package/lib/commonjs/web/handlers/PanGestureHandler.js +59 -0
  32. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  33. package/lib/commonjs/web/interfaces.js +10 -1
  34. package/lib/commonjs/web/interfaces.js.map +1 -1
  35. package/lib/commonjs/web/tools/EventManager.js +6 -0
  36. package/lib/commonjs/web/tools/EventManager.js.map +1 -1
  37. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -3
  38. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  39. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +5 -2
  40. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  41. package/lib/commonjs/web/tools/KeyboardEventManager.js +2 -2
  42. package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
  43. package/lib/commonjs/web/tools/PointerTracker.js +6 -30
  44. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  45. package/lib/commonjs/web/tools/WheelEventManager.js +74 -0
  46. package/lib/commonjs/web/tools/WheelEventManager.js.map +1 -0
  47. package/lib/commonjs/web/utils.js +16 -0
  48. package/lib/commonjs/web/utils.js.map +1 -1
  49. package/lib/module/RNGestureHandlerModule.web.js +16 -3
  50. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  51. package/lib/module/components/Pressable/Pressable.js +2 -6
  52. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  53. package/lib/module/components/ReanimatedDrawerLayout.js +365 -0
  54. package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -0
  55. package/lib/module/components/ReanimatedSwipeable.js +119 -145
  56. package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
  57. package/lib/module/findNodeHandle.js +3 -0
  58. package/lib/module/findNodeHandle.js.map +1 -0
  59. package/lib/module/findNodeHandle.web.js +32 -0
  60. package/lib/module/findNodeHandle.web.js.map +1 -0
  61. package/lib/module/handlers/createHandler.js +2 -1
  62. package/lib/module/handlers/createHandler.js.map +1 -1
  63. package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js +34 -0
  64. package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
  65. package/lib/module/handlers/gestures/GestureDetector/index.js +2 -1
  66. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  67. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +2 -2
  68. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
  69. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +1 -1
  70. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  71. package/lib/module/web/handlers/GestureHandler.js +4 -0
  72. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  73. package/lib/module/web/handlers/PanGestureHandler.js +58 -0
  74. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  75. package/lib/module/web/interfaces.js +8 -0
  76. package/lib/module/web/interfaces.js.map +1 -1
  77. package/lib/module/web/tools/EventManager.js +6 -0
  78. package/lib/module/web/tools/EventManager.js.map +1 -1
  79. package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -3
  80. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  81. package/lib/module/web/tools/GestureHandlerWebDelegate.js +3 -1
  82. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  83. package/lib/module/web/tools/KeyboardEventManager.js +2 -2
  84. package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
  85. package/lib/module/web/tools/PointerTracker.js +6 -30
  86. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  87. package/lib/module/web/tools/WheelEventManager.js +60 -0
  88. package/lib/module/web/tools/WheelEventManager.js.map +1 -0
  89. package/lib/module/web/utils.js +15 -0
  90. package/lib/module/web/utils.js.map +1 -1
  91. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +162 -0
  92. package/lib/typescript/components/ReanimatedSwipeable.d.ts +22 -16
  93. package/lib/typescript/findNodeHandle.d.ts +2 -0
  94. package/lib/typescript/findNodeHandle.web.d.ts +2 -0
  95. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +7 -0
  96. package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -1
  97. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +5 -0
  98. package/lib/typescript/web/interfaces.d.ts +16 -0
  99. package/lib/typescript/web/tools/EventManager.d.ts +2 -0
  100. package/lib/typescript/web/tools/PointerTracker.d.ts +2 -8
  101. package/lib/typescript/web/tools/WheelEventManager.d.ts +11 -0
  102. package/lib/typescript/web/utils.d.ts +2 -1
  103. package/package.json +3 -2
  104. package/src/RNGestureHandlerModule.web.ts +23 -4
  105. package/src/components/Pressable/Pressable.tsx +2 -6
  106. package/src/components/ReanimatedDrawerLayout.tsx +741 -0
  107. package/src/components/ReanimatedSwipeable.tsx +361 -305
  108. package/src/findNodeHandle.ts +3 -0
  109. package/src/findNodeHandle.web.ts +35 -0
  110. package/src/handlers/createHandler.tsx +2 -1
  111. package/src/handlers/gestures/GestureDetector/Wrap.web.tsx +44 -0
  112. package/src/handlers/gestures/GestureDetector/index.tsx +2 -1
  113. package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -1
  114. package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +1 -1
  115. package/src/web/handlers/GestureHandler.ts +5 -1
  116. package/src/web/handlers/PanGestureHandler.ts +69 -1
  117. package/src/web/interfaces.ts +17 -0
  118. package/src/web/tools/EventManager.ts +4 -0
  119. package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
  120. package/src/web/tools/GestureHandlerWebDelegate.ts +3 -1
  121. package/src/web/tools/KeyboardEventManager.ts +2 -2
  122. package/src/web/tools/PointerTracker.ts +6 -28
  123. package/src/web/tools/WheelEventManager.ts +48 -0
  124. package/src/web/utils.ts +47 -1
@@ -1,5 +1,11 @@
1
1
  require "json"
2
2
 
3
+
4
+ is_gh_example_app = ENV["GH_EXAMPLE_APP_NAME"] != nil
5
+
6
+ compilation_metadata_dir = "CompilationDatabase"
7
+ compilation_metadata_generation_flag = is_gh_example_app ? '-gen-cdb-fragment-path ' + compilation_metadata_dir : ''
8
+
3
9
  Pod::Spec.new do |s|
4
10
  # NPM package specification
5
11
  package = JSON.parse(File.read(File.join(File.dirname(__FILE__), "package.json")))
@@ -14,6 +20,9 @@ Pod::Spec.new do |s|
14
20
  s.source_files = "apple/**/*.{h,m,mm}"
15
21
  s.requires_arc = true
16
22
  s.platforms = { ios: '11.0', tvos: '11.0', osx: '10.15', visionos: '1.0' }
23
+ s.xcconfig = {
24
+ "OTHER_CFLAGS" => "$(inherited) " + compilation_metadata_generation_flag
25
+ }
17
26
 
18
27
  if defined?(install_modules_dependencies()) != nil
19
28
  install_modules_dependencies(s);
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/components/ReanimatedDrawerLayout",
3
+ "module": "../lib/module/components/ReanimatedDrawerLayout",
4
+ "react-native": "../src/components/ReanimatedDrawerLayout",
5
+ "types": "../lib/typescript/components/ReanimatedDrawerLayout.d.ts"
6
+ }
@@ -1,4 +1,5 @@
1
1
  import groovy.json.JsonSlurper
2
+ import com.android.build.gradle.tasks.ExternalNativeBuildJsonTask
2
3
 
3
4
  buildscript {
4
5
  def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNGH_kotlinVersion']
@@ -27,6 +28,10 @@ def safeExtGet(prop, fallback) {
27
28
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
28
29
  }
29
30
 
31
+ def isGHExampleApp() {
32
+ return safeExtGet("isGHExampleApp", false)
33
+ }
34
+
30
35
  def resolveReactNativeDirectory() {
31
36
  def reactNativeLocation = safeExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
32
37
  if (reactNativeLocation != null) {
@@ -170,6 +175,20 @@ android {
170
175
  }
171
176
  }
172
177
  }
178
+
179
+ if (isGHExampleApp()) {
180
+ tasks.withType(ExternalNativeBuildJsonTask) {
181
+ compileTask ->
182
+ compileTask.doLast {
183
+ def rootDir = new File("${project.projectDir}/..")
184
+ def generated = new File("${compileTask.abi.getCxxBuildFolder()}/compile_commands.json")
185
+ def output = new File("${rootDir}/compile_commands.json")
186
+ output.text = generated.text
187
+
188
+ println("Generated clangd metadata.")
189
+ }
190
+ }
191
+ }
173
192
  }
174
193
 
175
194
  def kotlin_version = safeExtGet('kotlinVersion', project.properties['RNGH_kotlinVersion'])
@@ -85,11 +85,15 @@ class GestureHandlerOrchestrator(
85
85
  private fun hasOtherHandlerToWaitFor(handler: GestureHandler<*>) =
86
86
  gestureHandlers.any { !isFinished(it.state) && shouldHandlerWaitForOther(handler, it) }
87
87
 
88
- private fun shouldBeCancelledByFinishedHandler(handler: GestureHandler<*>) = gestureHandlers.any { shouldHandlerWaitForOther(handler, it) && it.state == GestureHandler.STATE_END }
88
+ private fun shouldBeCancelledByFinishedHandler(handler: GestureHandler<*>) =
89
+ gestureHandlers.any { shouldHandlerWaitForOther(handler, it) && it.state == GestureHandler.STATE_END }
90
+
91
+ private fun shouldBeCancelledByActiveHandler(handler: GestureHandler<*>) =
92
+ gestureHandlers.any { handler.hasCommonPointers(it) && it.state == GestureHandler.STATE_ACTIVE && !canRunSimultaneously(handler, it) }
89
93
 
90
94
  private fun tryActivate(handler: GestureHandler<*>) {
91
95
  // If we are waiting for a gesture that has successfully finished, we should cancel handler
92
- if (shouldBeCancelledByFinishedHandler(handler)) {
96
+ if (shouldBeCancelledByFinishedHandler(handler) || shouldBeCancelledByActiveHandler(handler)) {
93
97
  handler.cancel()
94
98
  return
95
99
  }
@@ -57,6 +57,14 @@ class RotationGestureDetector(private val gestureListener: OnRotationGestureList
57
57
  currentTime = event.eventTime
58
58
  val firstPointerIndex = event.findPointerIndex(pointerIds[0])
59
59
  val secondPointerIndex = event.findPointerIndex(pointerIds[1])
60
+
61
+ if (
62
+ firstPointerIndex == MotionEvent.INVALID_POINTER_ID ||
63
+ secondPointerIndex == MotionEvent.INVALID_POINTER_ID
64
+ ) {
65
+ return
66
+ }
67
+
60
68
  val firstPtX = event.getX(firstPointerIndex)
61
69
  val firstPtY = event.getY(firstPointerIndex)
62
70
  val secondPtX = event.getX(secondPointerIndex)
@@ -68,6 +76,9 @@ class RotationGestureDetector(private val gestureListener: OnRotationGestureList
68
76
 
69
77
  // Angle diff should be positive when rotating in clockwise direction
70
78
  val angle = -atan2(vectorY.toDouble(), vectorX.toDouble())
79
+
80
+ tryUnpause(angle)
81
+
71
82
  rotation = if (previousAngle.isNaN()) {
72
83
  0.0
73
84
  } else previousAngle - angle
@@ -85,8 +96,29 @@ class RotationGestureDetector(private val gestureListener: OnRotationGestureList
85
96
  }
86
97
  }
87
98
 
99
+ /**
100
+ * Gesture pauses when second Pointer lifts
101
+ *
102
+ * Then Detector waits for a new second Pointer to arrive to continue Handling
103
+ * (last Pointer Lifting finishes the Gesture)
104
+ *
105
+ * @see tryPause
106
+ * @see tryUnpause
107
+ */
108
+ private var isPaused = false
109
+ private fun tryPause() {
110
+ if (isPaused) return
111
+ isPaused = true
112
+ }
113
+ private fun tryUnpause(eventAngle: Double) {
114
+ if (!isPaused) return
115
+ previousAngle = eventAngle
116
+ isPaused = false
117
+ }
118
+
88
119
  private fun finish() {
89
120
  if (isInProgress) {
121
+ isPaused = false
90
122
  isInProgress = false
91
123
  gestureListener?.onRotationEnd(this)
92
124
  }
@@ -99,33 +131,33 @@ class RotationGestureDetector(private val gestureListener: OnRotationGestureList
99
131
  pointerIds[0] = event.getPointerId(event.actionIndex)
100
132
  pointerIds[1] = MotionEvent.INVALID_POINTER_ID
101
133
  }
102
- MotionEvent.ACTION_POINTER_DOWN -> if (!isInProgress) {
103
- pointerIds[1] = event.getPointerId(event.actionIndex)
104
- isInProgress = true
105
- previousTime = event.eventTime
106
- previousAngle = Double.NaN
107
- updateCurrent(event)
108
- gestureListener?.onRotationBegin(this)
134
+ MotionEvent.ACTION_POINTER_DOWN -> {
135
+ if (!isInProgress || isPaused) {
136
+ pointerIds[1] = event.getPointerId(event.actionIndex)
137
+ updateCurrent(event)
138
+ }
139
+ if (!isInProgress) {
140
+ isInProgress = true
141
+ previousTime = event.eventTime
142
+ previousAngle = Double.NaN
143
+ gestureListener?.onRotationBegin(this)
144
+ }
109
145
  }
110
146
  MotionEvent.ACTION_MOVE -> if (isInProgress) {
111
147
  updateCurrent(event)
112
- gestureListener?.onRotation(this)
148
+ if (!isPaused) {
149
+ gestureListener?.onRotation(this)
150
+ }
113
151
  }
114
- MotionEvent.ACTION_POINTER_UP -> {
152
+ MotionEvent.ACTION_POINTER_UP -> if (isInProgress) {
115
153
  val pointerId = event.getPointerId(event.actionIndex)
116
-
117
- // All key pointers are up
118
- if (!isInProgress && pointerId == pointerIds[0]) {
119
- gestureListener?.onRotationEnd(this)
120
- }
121
-
122
- // One of the key pointers is up
123
- if (isInProgress && pointerIds.contains(pointerId)) {
124
- if (pointerId == pointerIds[0]) {
125
- pointerIds[0] = pointerIds[1]
126
- }
154
+ if (pointerId == pointerIds[0]) {
155
+ pointerIds[0] = pointerIds[1]
156
+ pointerIds[1] = MotionEvent.INVALID_POINTER_ID
157
+ tryPause()
158
+ } else if (pointerId == pointerIds[1]) {
127
159
  pointerIds[1] = MotionEvent.INVALID_POINTER_ID
128
- isInProgress = false
160
+ tryPause()
129
161
  }
130
162
  }
131
163
  MotionEvent.ACTION_UP -> finish()
@@ -71,8 +71,10 @@
71
71
  - (NSDictionary *)extractPointerData:(int)index forTouch:(RNGHUITouch *)touch
72
72
  {
73
73
  #if TARGET_OS_OSX
74
- CGPoint absolutePos = [touch locationInWindow];
75
- CGPoint relativePos = [touch.window.contentView convertPoint:absolutePos fromView:_gestureHandler.recognizer.view];
74
+ CGFloat windowHeight = touch.window.contentView.frame.size.height;
75
+ CGPoint yFlippedAbsolutePos = [touch locationInWindow];
76
+ CGPoint absolutePos = CGPointMake(yFlippedAbsolutePos.x, windowHeight - yFlippedAbsolutePos.y);
77
+ CGPoint relativePos = [_gestureHandler.recognizer.view convertPoint:absolutePos fromView:touch.window.contentView];
76
78
  #else
77
79
  CGPoint relativePos = [touch locationInView:_gestureHandler.recognizer.view];
78
80
  CGPoint absolutePos = [touch locationInView:_gestureHandler.recognizer.view.window];
@@ -25,6 +25,12 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
+ // init method is called inside attachGestureHandler function. However, this function may
29
+ // fail when received view is not valid HTML element. On the other hand, dropGestureHandler
30
+ // will be called even if attach failed, which will result in crash.
31
+ //
32
+ // We use this flag to check whether or not dropGestureHandler should be called.
33
+ let shouldPreventDrop = false;
28
34
  var _default = {
29
35
  handleSetJSResponder(tag, blockNativeResponder) {
30
36
  console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
@@ -62,8 +68,11 @@ var _default = {
62
68
 
63
69
  attachGestureHandler(handlerTag, // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
70
  newView, _actionType, propsRef) {
65
- if (!(newView instanceof HTMLElement || newView instanceof _react.default.Component)) {
66
- return;
71
+ if (!(newView instanceof Element || newView instanceof _react.default.Component)) {
72
+ shouldPreventDrop = true;
73
+ const handler = (0, _EnableNewWebImplementation.isNewWebImplementationEnabled)() ? _NodeManager.default.getHandler(handlerTag) : HammerNodeManager.getHandler(handlerTag);
74
+ const handlerName = handler.constructor.name;
75
+ throw new Error(`${handlerName} with tag ${handlerTag} received child that is not valid HTML element.`);
67
76
  }
68
77
 
69
78
  if ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
@@ -94,6 +103,10 @@ var _default = {
94
103
  },
95
104
 
96
105
  dropGestureHandler(handlerTag) {
106
+ if (shouldPreventDrop) {
107
+ return;
108
+ }
109
+
97
110
  if ((0, _EnableNewWebImplementation.isNewWebImplementationEnabled)()) {
98
111
  _NodeManager.default.dropGestureHandler(handlerTag);
99
112
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Gestures","Error","GestureClass","NodeManager","GestureHandlerWebDelegate","InteractionManager","getInstance","configureInteractions","getHandler","HammerGestures","HammerNodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","HTMLElement","React","Component","init","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;eAEe;AACbA,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAHY;;AAIbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GANY;;AAObE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA,QAAI,gEAAJ,EAAqC;AACnC,UAAI,EAAEF,WAAW,IAAIG,kBAAjB,CAAJ,EAAgC;AAC9B,cAAM,IAAIC,KAAJ,CACH,iCAAgCJ,WAAY,2BADzC,CAAN;AAGD;;AAED,YAAMK,YAAY,GAAGF,mBAASH,WAAT,CAArB;;AACAM,2BAAYP,oBAAZ,CACEE,UADF,EAEE,IAAII,YAAJ,CAAiB,IAAIE,oDAAJ,EAAjB,CAFF;;AAIAC,kCAAmBC,WAAnB,GAAiCC,qBAAjC,CACEJ,qBAAYK,UAAZ,CAAuBV,UAAvB,CADF,EAEEC,MAFF;AAID,KAhBD,MAgBO;AACL,UAAI,EAA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,EAAqC;AACnC,aAAOK,qBAAYK,UAAZ,CAAuBV,UAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOY,iBAAiB,CAACF,UAAlB,CAA6BV,UAA7B,CAAP;AACD;AACF,GAnFY;;AAoFb0B,EAAAA,kBAAkB,CAAC1B,UAAD,EAAqB;AACrC,QAAI,gEAAJ,EAAqC;AACnCK,2BAAYqB,kBAAZ,CAA+B1B,UAA/B;AACD,KAFD,MAEO;AACLY,MAAAA,iBAAiB,CAACc,kBAAlB,CAAqC1B,UAArC;AACD;AACF,GA1FY;;AA2Fb;AACA2B,EAAAA,eAAe,GAAG,CAAE;;AA5FP,C","sourcesContent":["import React from 'react';\n\nimport type { ActionType } from './ActionType';\nimport { isNewWebImplementationEnabled } from './EnableNewWebImplementation';\nimport { Gestures, HammerGestures } from './web/Gestures';\nimport type { Config } from './web/interfaces';\nimport InteractionManager from './web/tools/InteractionManager';\nimport NodeManager from './web/tools/NodeManager';\nimport * as HammerNodeManager from './web_hammer/NodeManager';\nimport { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';\n\nexport default {\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n if (isNewWebImplementationEnabled()) {\n if (!(handlerName in Gestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(\n handlerTag,\n new GestureClass(new GestureHandlerWebDelegate())\n );\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n config as unknown as Config\n );\n } else {\n if (!(handlerName in HammerGestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n // @ts-ignore If it doesn't exist, the error is thrown\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const GestureClass = HammerGestures[handlerName];\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());\n }\n\n this.updateGestureHandler(handlerTag, config as unknown as Config);\n },\n attachGestureHandler(\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n if (\n !(newView instanceof HTMLElement || newView instanceof React.Component)\n ) {\n return;\n }\n\n if (isNewWebImplementationEnabled()) {\n // @ts-ignore Types should be HTMLElement or React.Component\n NodeManager.getHandler(handlerTag).init(newView, propsRef);\n } else {\n // @ts-ignore Types should be HTMLElement or React.Component\n HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);\n }\n },\n updateGestureHandler(handlerTag: number, newConfig: Config) {\n if (isNewWebImplementationEnabled()) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n newConfig\n );\n } else {\n HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n }\n },\n getGestureHandlerNode(handlerTag: number) {\n if (isNewWebImplementationEnabled()) {\n return NodeManager.getHandler(handlerTag);\n } else {\n return HammerNodeManager.getHandler(handlerTag);\n }\n },\n dropGestureHandler(handlerTag: number) {\n if (isNewWebImplementationEnabled()) {\n NodeManager.dropGestureHandler(handlerTag);\n } else {\n HammerNodeManager.dropGestureHandler(handlerTag);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n flushOperations() {},\n};\n"]}
1
+ {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["shouldPreventDrop","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Gestures","Error","GestureClass","NodeManager","GestureHandlerWebDelegate","InteractionManager","getInstance","configureInteractions","getHandler","HammerGestures","HammerNodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","Element","React","Component","handler","constructor","name","init","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAIA,iBAAiB,GAAG,KAAxB;eAEe;AACbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAHY;;AAIbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GANY;;AAObE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA,QAAI,gEAAJ,EAAqC;AACnC,UAAI,EAAEF,WAAW,IAAIG,kBAAjB,CAAJ,EAAgC;AAC9B,cAAM,IAAIC,KAAJ,CACH,iCAAgCJ,WAAY,2BADzC,CAAN;AAGD;;AAED,YAAMK,YAAY,GAAGF,mBAASH,WAAT,CAArB;;AACAM,2BAAYP,oBAAZ,CACEE,UADF,EAEE,IAAII,YAAJ,CAAiB,IAAIE,oDAAJ,EAAjB,CAFF;;AAIAC,kCAAmBC,WAAnB,GAAiCC,qBAAjC,CACEJ,qBAAYK,UAAZ,CAAuBV,UAAvB,CADF,EAEEC,MAFF;AAID,KAhBD,MAgBO;AACL,UAAI,EAAEF,WAAW,IAAIY,wBAAjB,CAAJ,EAAsC;AACpC,cAAM,IAAIR,KAAJ,CACH,iCAAgCJ,WAAY,2BADzC,CAAN;AAGD,OALI,CAOL;AACA;;;AACA,YAAMK,YAAY,GAAGO,yBAAeZ,WAAf,CAArB,CATK,CAUL;;AACAa,MAAAA,iBAAiB,CAACd,oBAAlB,CAAuCE,UAAvC,EAAmD,IAAII,YAAJ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CAAC5B,UAAD,EAAqB;AACxC,QAAI,gEAAJ,EAAqC;AACnC,aAAOK,qBAAYK,UAAZ,CAAuBV,UAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOY,iBAAiB,CAACF,UAAlB,CAA6BV,UAA7B,CAAP;AACD;AACF,GA3FY;;AA4Fb6B,EAAAA,kBAAkB,CAAC7B,UAAD,EAAqB;AACrC,QAAIT,iBAAJ,EAAuB;AACrB;AACD;;AAED,QAAI,gEAAJ,EAAqC;AACnCc,2BAAYwB,kBAAZ,CAA+B7B,UAA/B;AACD,KAFD,MAEO;AACLY,MAAAA,iBAAiB,CAACiB,kBAAlB,CAAqC7B,UAArC;AACD;AACF,GAtGY;;AAuGb;AACA8B,EAAAA,eAAe,GAAG,CAAE;;AAxGP,C","sourcesContent":["import React from 'react';\n\nimport type { ActionType } from './ActionType';\nimport { isNewWebImplementationEnabled } from './EnableNewWebImplementation';\nimport { Gestures, HammerGestures } from './web/Gestures';\nimport type { Config } from './web/interfaces';\nimport InteractionManager from './web/tools/InteractionManager';\nimport NodeManager from './web/tools/NodeManager';\nimport * as HammerNodeManager from './web_hammer/NodeManager';\nimport { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';\n\n// init method is called inside attachGestureHandler function. However, this function may\n// fail when received view is not valid HTML element. On the other hand, dropGestureHandler\n// will be called even if attach failed, which will result in crash.\n//\n// We use this flag to check whether or not dropGestureHandler should be called.\nlet shouldPreventDrop = false;\n\nexport default {\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n if (isNewWebImplementationEnabled()) {\n if (!(handlerName in Gestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(\n handlerTag,\n new GestureClass(new GestureHandlerWebDelegate())\n );\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n config as unknown as Config\n );\n } else {\n if (!(handlerName in HammerGestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n // @ts-ignore If it doesn't exist, the error is thrown\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const GestureClass = HammerGestures[handlerName];\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());\n }\n\n this.updateGestureHandler(handlerTag, config as unknown as Config);\n },\n attachGestureHandler(\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n if (!(newView instanceof Element || newView instanceof React.Component)) {\n shouldPreventDrop = true;\n\n const handler = isNewWebImplementationEnabled()\n ? NodeManager.getHandler(handlerTag)\n : HammerNodeManager.getHandler(handlerTag);\n\n const handlerName = handler.constructor.name;\n\n throw new Error(\n `${handlerName} with tag ${handlerTag} received child that is not valid HTML element.`\n );\n }\n\n if (isNewWebImplementationEnabled()) {\n // @ts-ignore Types should be HTMLElement or React.Component\n NodeManager.getHandler(handlerTag).init(newView, propsRef);\n } else {\n // @ts-ignore Types should be HTMLElement or React.Component\n HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);\n }\n },\n updateGestureHandler(handlerTag: number, newConfig: Config) {\n if (isNewWebImplementationEnabled()) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n newConfig\n );\n } else {\n HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n }\n },\n getGestureHandlerNode(handlerTag: number) {\n if (isNewWebImplementationEnabled()) {\n return NodeManager.getHandler(handlerTag);\n } else {\n return HammerNodeManager.getHandler(handlerTag);\n }\n },\n dropGestureHandler(handlerTag: number) {\n if (shouldPreventDrop) {\n return;\n }\n\n if (isNewWebImplementationEnabled()) {\n NodeManager.dropGestureHandler(handlerTag);\n } else {\n HammerNodeManager.dropGestureHandler(handlerTag);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n flushOperations() {},\n};\n"]}
@@ -234,7 +234,7 @@ function Pressable(props) {
234
234
 
235
235
  const buttonGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.Native().onBegin(() => {
236
236
  // Android sets BEGAN state on press down
237
- if (_reactNative.Platform.OS === 'android') {
237
+ if (_reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'macos') {
238
238
  isTouchPropagationAllowed.current = true;
239
239
  }
240
240
  }).onStart(() => {
@@ -281,11 +281,7 @@ function Pressable(props) {
281
281
  gesture.enabled(isPressableEnabled);
282
282
  gesture.runOnJS(true);
283
283
  gesture.hitSlop(appliedHitSlop);
284
- gesture.shouldCancelWhenOutside(false);
285
-
286
- if (_reactNative.Platform.OS !== 'web') {
287
- gesture.shouldCancelWhenOutside(true);
288
- }
284
+ gesture.shouldCancelWhenOutside(_reactNative.Platform.OS === 'web' ? false : true);
289
285
  } // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area
290
286
 
291
287
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Pressable.tsx"],"names":["DEFAULT_LONG_PRESS_DURATION","Pressable","props","testOnly_pressed","hitSlop","pressRetentionOffset","delayHoverIn","onHoverIn","delayHoverOut","onHoverOut","delayLongPress","unstable_pressDelay","onPress","onPressIn","onPressOut","onLongPress","style","children","android_disableSound","android_ripple","disabled","remainingProps","pressedState","setPressedState","pressableRef","isPressCallbackEnabled","hasPassedBoundsChecks","shouldPreventNativeEffects","normalizedHitSlop","normalizedPressRetentionOffset","hoverInTimeout","hoverOutTimeout","hoverGesture","Gesture","Hover","manualActivation","cancelsTouchesInView","onBegin","event","current","clearTimeout","setTimeout","onFinalize","pressDelayTimeoutRef","isTouchPropagationAllowed","deferredEventPayload","pressInHandler","handlingOnTouchesDown","pressOutHandler","nativeEvent","touches","length","changedTouches","longPressTimeoutRef","onEndHandlingTouchesDown","cancelledMidPress","activateLongPress","longPressMinDuration","pressAndTouchGesture","LongPress","minDuration","INT32_MAX","maxDistance","onTouchesDown","measure","_x","_y","width","height","at","onTouchesUp","onTouchesCancelled","allTouches","buttonGesture","Native","Platform","OS","onStart","appliedHitSlop","isPressableEnabled","gestures","gesture","enabled","runOnJS","shouldCancelWhenOutside","Simultaneous","defaultRippleColor","undefined","pointerStyle","cursor","styleProp","pressed","childrenProp","color","radius","__DEV__"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAQA;;AACA;;AAOA;;AAEA;;;;;;;;;;AAEA,MAAMA,2BAA2B,GAAG,GAApC;;AAEe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;AAAA;;AACvD,QAAM;AACJC,IAAAA,gBADI;AAEJC,IAAAA,OAFI;AAGJC,IAAAA,oBAHI;AAIJC,IAAAA,YAJI;AAKJC,IAAAA,SALI;AAMJC,IAAAA,aANI;AAOJC,IAAAA,UAPI;AAQJC,IAAAA,cARI;AASJC,IAAAA,mBATI;AAUJC,IAAAA,OAVI;AAWJC,IAAAA,SAXI;AAYJC,IAAAA,UAZI;AAaJC,IAAAA,WAbI;AAcJC,IAAAA,KAdI;AAeJC,IAAAA,QAfI;AAgBJC,IAAAA,oBAhBI;AAiBJC,IAAAA,cAjBI;AAkBJC,IAAAA,QAlBI;AAmBJ,OAAGC;AAnBC,MAoBFnB,KApBJ;AAsBA,QAAM,CAACoB,YAAD,EAAeC,eAAf,IAAkC,qBAASpB,gBAAT,aAASA,gBAAT,cAASA,gBAAT,GAA6B,KAA7B,CAAxC;AAEA,QAAMqB,YAAY,GAAG,mBAAa,IAAb,CAArB,CAzBuD,CA2BvD;;AACA,QAAMC,sBAAsB,GAAG,mBAAgB,IAAhB,CAA/B;AACA,QAAMC,qBAAqB,GAAG,mBAA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\nimport { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../../handlers/gestures/GestureDetector';\nimport { PressableEvent, PressableProps } from './PressableProps';\nimport {\n Insets,\n Platform,\n StyleProp,\n View,\n ViewStyle,\n processColor,\n} from 'react-native';\nimport NativeButton from '../GestureHandlerButton';\nimport {\n numberAsInset,\n gestureToPressableEvent,\n isTouchWithinInset,\n gestureTouchToPressableEvent,\n addInsets,\n} from './utils';\nimport { PressabilityDebugView } from '../../handlers/PressabilityDebugView';\nimport { GestureTouchEvent } from '../../handlers/gestureHandlerCommon';\nimport { INT32_MAX } from '../../utils';\n\nconst DEFAULT_LONG_PRESS_DURATION = 500;\n\nexport default function Pressable(props: PressableProps) {\n const {\n testOnly_pressed,\n hitSlop,\n pressRetentionOffset,\n delayHoverIn,\n onHoverIn,\n delayHoverOut,\n onHoverOut,\n delayLongPress,\n unstable_pressDelay,\n onPress,\n onPressIn,\n onPressOut,\n onLongPress,\n style,\n children,\n android_disableSound,\n android_ripple,\n disabled,\n ...remainingProps\n } = props;\n\n const [pressedState, setPressedState] = useState(testOnly_pressed ?? false);\n\n const pressableRef = useRef<View>(null);\n\n // Disabled when onLongPress has been called\n const isPressCallbackEnabled = useRef<boolean>(true);\n const hasPassedBoundsChecks = useRef<boolean>(false);\n const shouldPreventNativeEffects = useRef<boolean>(false);\n\n const normalizedHitSlop: Insets = useMemo(\n () =>\n typeof hitSlop === 'number' ? numberAsInset(hitSlop) : hitSlop ?? {},\n [hitSlop]\n );\n\n const normalizedPressRetentionOffset: Insets = useMemo(\n () =>\n typeof pressRetentionOffset === 'number'\n ? numberAsInset(pressRetentionOffset)\n : pressRetentionOffset ?? {},\n [pressRetentionOffset]\n );\n\n const hoverInTimeout = useRef<number | null>(null);\n const hoverOutTimeout = useRef<number | null>(null);\n\n const hoverGesture = useMemo(\n () =>\n Gesture.Hover()\n .manualActivation(true) // Stops Hover from blocking Native gesture activation on web\n .cancelsTouchesInView(false)\n .onBegin((event) => {\n if (hoverOutTimeout.current) {\n clearTimeout(hoverOutTimeout.current);\n }\n if (delayHoverIn) {\n hoverInTimeout.current = setTimeout(\n () => onHoverIn?.(gestureToPressableEvent(event)),\n delayHoverIn\n );\n return;\n }\n onHoverIn?.(gestureToPressableEvent(event));\n })\n .onFinalize((event) => {\n if (hoverInTimeout.current) {\n clearTimeout(hoverInTimeout.current);\n }\n if (delayHoverOut) {\n hoverOutTimeout.current = setTimeout(\n () => onHoverOut?.(gestureToPressableEvent(event)),\n delayHoverOut\n );\n return;\n }\n onHoverOut?.(gestureToPressableEvent(event));\n }),\n [delayHoverIn, delayHoverOut, onHoverIn, onHoverOut]\n );\n\n const pressDelayTimeoutRef = useRef<number | null>(null);\n const isTouchPropagationAllowed = useRef<boolean>(false);\n\n // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use\n const deferredEventPayload = useRef<PressableEvent | null>(null);\n\n const pressInHandler = useCallback(\n (event: PressableEvent) => {\n if (handlingOnTouchesDown.current) {\n deferredEventPayload.current = event;\n }\n\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n deferredEventPayload.current = null;\n\n onPressIn?.(event);\n isPressCallbackEnabled.current = true;\n pressDelayTimeoutRef.current = null;\n setPressedState(true);\n },\n [onPressIn]\n );\n\n const pressOutHandler = useCallback(\n (event: PressableEvent) => {\n if (\n !hasPassedBoundsChecks.current ||\n event.nativeEvent.touches.length >\n event.nativeEvent.changedTouches.length\n ) {\n return;\n }\n\n if (unstable_pressDelay && pressDelayTimeoutRef.current !== null) {\n // When delay is preemptively finished by lifting touches,\n // we want to immediately activate it's effects - pressInHandler,\n // even though we are located at the pressOutHandler\n clearTimeout(pressDelayTimeoutRef.current);\n pressInHandler(event);\n }\n\n if (deferredEventPayload.current) {\n onPressIn?.(deferredEventPayload.current);\n deferredEventPayload.current = null;\n }\n\n onPressOut?.(event);\n\n if (isPressCallbackEnabled.current) {\n onPress?.(event);\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n\n isTouchPropagationAllowed.current = false;\n hasPassedBoundsChecks.current = false;\n isPressCallbackEnabled.current = true;\n setPressedState(false);\n },\n [onPress, onPressIn, onPressOut, pressInHandler, unstable_pressDelay]\n );\n\n const handlingOnTouchesDown = useRef<boolean>(false);\n const onEndHandlingTouchesDown = useRef<(() => void) | null>(null);\n const cancelledMidPress = useRef<boolean>(false);\n\n const activateLongPress = useCallback(\n (event: GestureTouchEvent) => {\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n onLongPress?.(gestureTouchToPressableEvent(event));\n isPressCallbackEnabled.current = false;\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n },\n [onLongPress]\n );\n\n const longPressTimeoutRef = useRef<number | null>(null);\n const longPressMinDuration =\n (delayLongPress ?? DEFAULT_LONG_PRESS_DURATION) +\n (unstable_pressDelay ?? 0);\n\n const pressAndTouchGesture = useMemo(\n () =>\n Gesture.LongPress()\n .minDuration(INT32_MAX) // Stops long press from blocking native gesture\n .maxDistance(INT32_MAX) // Stops long press from cancelling after set distance\n .cancelsTouchesInView(false)\n .onTouchesDown((event) => {\n handlingOnTouchesDown.current = true;\n pressableRef.current?.measure((_x, _y, width, height) => {\n if (\n !isTouchWithinInset(\n {\n width,\n height,\n },\n normalizedHitSlop,\n event.changedTouches.at(-1)\n ) ||\n hasPassedBoundsChecks.current ||\n cancelledMidPress.current\n ) {\n cancelledMidPress.current = false;\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n return;\n }\n\n hasPassedBoundsChecks.current = true;\n\n // In case of multiple touches, the first one starts long press gesture\n if (longPressTimeoutRef.current === null) {\n // Start long press gesture timer\n longPressTimeoutRef.current = setTimeout(\n () => activateLongPress(event),\n longPressMinDuration\n );\n }\n\n if (unstable_pressDelay) {\n pressDelayTimeoutRef.current = setTimeout(() => {\n pressInHandler(gestureTouchToPressableEvent(event));\n }, unstable_pressDelay);\n } else {\n pressInHandler(gestureTouchToPressableEvent(event));\n }\n\n onEndHandlingTouchesDown.current?.();\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n });\n })\n .onTouchesUp((event) => {\n if (handlingOnTouchesDown.current) {\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n // On iOS, short taps will make LongPress gesture call onTouchesUp before Native gesture calls onStart\n // This variable ensures that onStart isn't detected as the first gesture since Pressable is pressed.\n if (deferredEventPayload.current !== null) {\n shouldPreventNativeEffects.current = true;\n }\n pressOutHandler(gestureTouchToPressableEvent(event));\n })\n .onTouchesCancelled((event) => {\n isPressCallbackEnabled.current = false;\n\n if (handlingOnTouchesDown.current) {\n cancelledMidPress.current = true;\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n\n if (\n !hasPassedBoundsChecks.current ||\n event.allTouches.length > event.changedTouches.length\n ) {\n return;\n }\n\n pressOutHandler(gestureTouchToPressableEvent(event));\n }),\n [\n activateLongPress,\n longPressMinDuration,\n normalizedHitSlop,\n pressInHandler,\n pressOutHandler,\n unstable_pressDelay,\n ]\n );\n\n // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events\n const buttonGesture = useMemo(\n () =>\n Gesture.Native()\n .onBegin(() => {\n // Android sets BEGAN state on press down\n if (Platform.OS === 'android') {\n isTouchPropagationAllowed.current = true;\n }\n })\n .onStart(() => {\n if (Platform.OS === 'web') {\n isTouchPropagationAllowed.current = true;\n }\n\n // iOS sets ACTIVE state on press down\n if (Platform.OS !== 'ios') {\n return;\n }\n\n if (deferredEventPayload.current) {\n isTouchPropagationAllowed.current = true;\n\n if (hasPassedBoundsChecks.current) {\n pressInHandler(deferredEventPayload.current);\n deferredEventPayload.current = null;\n } else {\n pressOutHandler(deferredEventPayload.current);\n isTouchPropagationAllowed.current = false;\n }\n\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n isTouchPropagationAllowed.current = true;\n return;\n }\n\n if (shouldPreventNativeEffects.current) {\n shouldPreventNativeEffects.current = false;\n return;\n }\n\n isTouchPropagationAllowed.current = true;\n }),\n [pressInHandler, pressOutHandler]\n );\n\n const appliedHitSlop = addInsets(\n normalizedHitSlop,\n normalizedPressRetentionOffset\n );\n\n const isPressableEnabled = disabled !== true;\n\n const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];\n\n for (const gesture of gestures) {\n gesture.enabled(isPressableEnabled);\n gesture.runOnJS(true);\n gesture.hitSlop(appliedHitSlop);\n gesture.shouldCancelWhenOutside(false);\n\n if (Platform.OS !== 'web') {\n gesture.shouldCancelWhenOutside(true);\n }\n }\n\n // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area\n buttonGesture.hitSlop(normalizedHitSlop);\n\n const gesture = Gesture.Simultaneous(...gestures);\n\n const defaultRippleColor = android_ripple ? undefined : 'transparent';\n\n // `cursor: 'pointer'` on `RNButton` crashes iOS\n const pointerStyle: StyleProp<ViewStyle> =\n Platform.OS === 'web' ? { cursor: 'pointer' } : {};\n\n const styleProp =\n typeof style === 'function' ? style({ pressed: pressedState }) : style;\n\n const childrenProp =\n typeof children === 'function'\n ? children({ pressed: pressedState })\n : children;\n\n return (\n <GestureDetector gesture={gesture}>\n <NativeButton\n {...remainingProps}\n ref={pressableRef}\n hitSlop={appliedHitSlop}\n enabled={isPressableEnabled}\n touchSoundDisabled={android_disableSound ?? undefined}\n rippleColor={processColor(android_ripple?.color ?? defaultRippleColor)}\n rippleRadius={android_ripple?.radius ?? undefined}\n style={[pointerStyle, styleProp]}>\n {childrenProp}\n {__DEV__ ? (\n <PressabilityDebugView color=\"red\" hitSlop={normalizedHitSlop} />\n ) : null}\n </NativeButton>\n </GestureDetector>\n );\n}\n"]}
1
+ {"version":3,"sources":["Pressable.tsx"],"names":["DEFAULT_LONG_PRESS_DURATION","Pressable","props","testOnly_pressed","hitSlop","pressRetentionOffset","delayHoverIn","onHoverIn","delayHoverOut","onHoverOut","delayLongPress","unstable_pressDelay","onPress","onPressIn","onPressOut","onLongPress","style","children","android_disableSound","android_ripple","disabled","remainingProps","pressedState","setPressedState","pressableRef","isPressCallbackEnabled","hasPassedBoundsChecks","shouldPreventNativeEffects","normalizedHitSlop","normalizedPressRetentionOffset","hoverInTimeout","hoverOutTimeout","hoverGesture","Gesture","Hover","manualActivation","cancelsTouchesInView","onBegin","event","current","clearTimeout","setTimeout","onFinalize","pressDelayTimeoutRef","isTouchPropagationAllowed","deferredEventPayload","pressInHandler","handlingOnTouchesDown","pressOutHandler","nativeEvent","touches","length","changedTouches","longPressTimeoutRef","onEndHandlingTouchesDown","cancelledMidPress","activateLongPress","longPressMinDuration","pressAndTouchGesture","LongPress","minDuration","INT32_MAX","maxDistance","onTouchesDown","measure","_x","_y","width","height","at","onTouchesUp","onTouchesCancelled","allTouches","buttonGesture","Native","Platform","OS","onStart","appliedHitSlop","isPressableEnabled","gestures","gesture","enabled","runOnJS","shouldCancelWhenOutside","Simultaneous","defaultRippleColor","undefined","pointerStyle","cursor","styleProp","pressed","childrenProp","color","radius","__DEV__"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAQA;;AACA;;AAOA;;AAEA;;;;;;;;;;AAEA,MAAMA,2BAA2B,GAAG,GAApC;;AAEe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;AAAA;;AACvD,QAAM;AACJC,IAAAA,gBADI;AAEJC,IAAAA,OAFI;AAGJC,IAAAA,oBAHI;AAIJC,IAAAA,YAJI;AAKJC,IAAAA,SALI;AAMJC,IAAAA,aANI;AAOJC,IAAAA,UAPI;AAQJC,IAAAA,cARI;AASJC,IAAAA,mBATI;AAUJC,IAAAA,OAVI;AAWJC,IAAAA,SAXI;AAYJC,IAAAA,UAZI;AAaJC,IAAAA,WAbI;AAcJC,IAAAA,KAdI;AAeJC,IAAAA,QAfI;AAgBJC,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C,CANf;AAOE,IAAA,YAAY,2BAAEnE,cAAF,aAAEA,cAAF,uBAAEA,cAAc,CAAE2E,MAAlB,yEAA4BP,SAP1C;AAQE,IAAA,KAAK,EAAE,CAACC,YAAD,EAAeE,SAAf;AART,MASGE,YATH,EAUGG,OAAO,gBACN,6BAAC,4CAAD;AAAuB,IAAA,KAAK,EAAC,KAA7B;AAAmC,IAAA,OAAO,EAAEnE;AAA5C,IADM,GAEJ,IAZN,CADF,CADF;AAkBD","sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../../handlers/gestures/GestureDetector';\nimport { PressableEvent, PressableProps } from './PressableProps';\nimport {\n Insets,\n Platform,\n StyleProp,\n View,\n ViewStyle,\n processColor,\n} from 'react-native';\nimport NativeButton from '../GestureHandlerButton';\nimport {\n numberAsInset,\n gestureToPressableEvent,\n isTouchWithinInset,\n gestureTouchToPressableEvent,\n addInsets,\n} from './utils';\nimport { PressabilityDebugView } from '../../handlers/PressabilityDebugView';\nimport { GestureTouchEvent } from '../../handlers/gestureHandlerCommon';\nimport { INT32_MAX } from '../../utils';\n\nconst DEFAULT_LONG_PRESS_DURATION = 500;\n\nexport default function Pressable(props: PressableProps) {\n const {\n testOnly_pressed,\n hitSlop,\n pressRetentionOffset,\n delayHoverIn,\n onHoverIn,\n delayHoverOut,\n onHoverOut,\n delayLongPress,\n unstable_pressDelay,\n onPress,\n onPressIn,\n onPressOut,\n onLongPress,\n style,\n children,\n android_disableSound,\n android_ripple,\n disabled,\n ...remainingProps\n } = props;\n\n const [pressedState, setPressedState] = useState(testOnly_pressed ?? false);\n\n const pressableRef = useRef<View>(null);\n\n // Disabled when onLongPress has been called\n const isPressCallbackEnabled = useRef<boolean>(true);\n const hasPassedBoundsChecks = useRef<boolean>(false);\n const shouldPreventNativeEffects = useRef<boolean>(false);\n\n const normalizedHitSlop: Insets = useMemo(\n () =>\n typeof hitSlop === 'number' ? numberAsInset(hitSlop) : hitSlop ?? {},\n [hitSlop]\n );\n\n const normalizedPressRetentionOffset: Insets = useMemo(\n () =>\n typeof pressRetentionOffset === 'number'\n ? numberAsInset(pressRetentionOffset)\n : pressRetentionOffset ?? {},\n [pressRetentionOffset]\n );\n\n const hoverInTimeout = useRef<number | null>(null);\n const hoverOutTimeout = useRef<number | null>(null);\n\n const hoverGesture = useMemo(\n () =>\n Gesture.Hover()\n .manualActivation(true) // Stops Hover from blocking Native gesture activation on web\n .cancelsTouchesInView(false)\n .onBegin((event) => {\n if (hoverOutTimeout.current) {\n clearTimeout(hoverOutTimeout.current);\n }\n if (delayHoverIn) {\n hoverInTimeout.current = setTimeout(\n () => onHoverIn?.(gestureToPressableEvent(event)),\n delayHoverIn\n );\n return;\n }\n onHoverIn?.(gestureToPressableEvent(event));\n })\n .onFinalize((event) => {\n if (hoverInTimeout.current) {\n clearTimeout(hoverInTimeout.current);\n }\n if (delayHoverOut) {\n hoverOutTimeout.current = setTimeout(\n () => onHoverOut?.(gestureToPressableEvent(event)),\n delayHoverOut\n );\n return;\n }\n onHoverOut?.(gestureToPressableEvent(event));\n }),\n [delayHoverIn, delayHoverOut, onHoverIn, onHoverOut]\n );\n\n const pressDelayTimeoutRef = useRef<number | null>(null);\n const isTouchPropagationAllowed = useRef<boolean>(false);\n\n // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use\n const deferredEventPayload = useRef<PressableEvent | null>(null);\n\n const pressInHandler = useCallback(\n (event: PressableEvent) => {\n if (handlingOnTouchesDown.current) {\n deferredEventPayload.current = event;\n }\n\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n deferredEventPayload.current = null;\n\n onPressIn?.(event);\n isPressCallbackEnabled.current = true;\n pressDelayTimeoutRef.current = null;\n setPressedState(true);\n },\n [onPressIn]\n );\n\n const pressOutHandler = useCallback(\n (event: PressableEvent) => {\n if (\n !hasPassedBoundsChecks.current ||\n event.nativeEvent.touches.length >\n event.nativeEvent.changedTouches.length\n ) {\n return;\n }\n\n if (unstable_pressDelay && pressDelayTimeoutRef.current !== null) {\n // When delay is preemptively finished by lifting touches,\n // we want to immediately activate it's effects - pressInHandler,\n // even though we are located at the pressOutHandler\n clearTimeout(pressDelayTimeoutRef.current);\n pressInHandler(event);\n }\n\n if (deferredEventPayload.current) {\n onPressIn?.(deferredEventPayload.current);\n deferredEventPayload.current = null;\n }\n\n onPressOut?.(event);\n\n if (isPressCallbackEnabled.current) {\n onPress?.(event);\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n\n isTouchPropagationAllowed.current = false;\n hasPassedBoundsChecks.current = false;\n isPressCallbackEnabled.current = true;\n setPressedState(false);\n },\n [onPress, onPressIn, onPressOut, pressInHandler, unstable_pressDelay]\n );\n\n const handlingOnTouchesDown = useRef<boolean>(false);\n const onEndHandlingTouchesDown = useRef<(() => void) | null>(null);\n const cancelledMidPress = useRef<boolean>(false);\n\n const activateLongPress = useCallback(\n (event: GestureTouchEvent) => {\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n onLongPress?.(gestureTouchToPressableEvent(event));\n isPressCallbackEnabled.current = false;\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n },\n [onLongPress]\n );\n\n const longPressTimeoutRef = useRef<number | null>(null);\n const longPressMinDuration =\n (delayLongPress ?? DEFAULT_LONG_PRESS_DURATION) +\n (unstable_pressDelay ?? 0);\n\n const pressAndTouchGesture = useMemo(\n () =>\n Gesture.LongPress()\n .minDuration(INT32_MAX) // Stops long press from blocking native gesture\n .maxDistance(INT32_MAX) // Stops long press from cancelling after set distance\n .cancelsTouchesInView(false)\n .onTouchesDown((event) => {\n handlingOnTouchesDown.current = true;\n pressableRef.current?.measure((_x, _y, width, height) => {\n if (\n !isTouchWithinInset(\n {\n width,\n height,\n },\n normalizedHitSlop,\n event.changedTouches.at(-1)\n ) ||\n hasPassedBoundsChecks.current ||\n cancelledMidPress.current\n ) {\n cancelledMidPress.current = false;\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n return;\n }\n\n hasPassedBoundsChecks.current = true;\n\n // In case of multiple touches, the first one starts long press gesture\n if (longPressTimeoutRef.current === null) {\n // Start long press gesture timer\n longPressTimeoutRef.current = setTimeout(\n () => activateLongPress(event),\n longPressMinDuration\n );\n }\n\n if (unstable_pressDelay) {\n pressDelayTimeoutRef.current = setTimeout(() => {\n pressInHandler(gestureTouchToPressableEvent(event));\n }, unstable_pressDelay);\n } else {\n pressInHandler(gestureTouchToPressableEvent(event));\n }\n\n onEndHandlingTouchesDown.current?.();\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n });\n })\n .onTouchesUp((event) => {\n if (handlingOnTouchesDown.current) {\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n // On iOS, short taps will make LongPress gesture call onTouchesUp before Native gesture calls onStart\n // This variable ensures that onStart isn't detected as the first gesture since Pressable is pressed.\n if (deferredEventPayload.current !== null) {\n shouldPreventNativeEffects.current = true;\n }\n pressOutHandler(gestureTouchToPressableEvent(event));\n })\n .onTouchesCancelled((event) => {\n isPressCallbackEnabled.current = false;\n\n if (handlingOnTouchesDown.current) {\n cancelledMidPress.current = true;\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n\n if (\n !hasPassedBoundsChecks.current ||\n event.allTouches.length > event.changedTouches.length\n ) {\n return;\n }\n\n pressOutHandler(gestureTouchToPressableEvent(event));\n }),\n [\n activateLongPress,\n longPressMinDuration,\n normalizedHitSlop,\n pressInHandler,\n pressOutHandler,\n unstable_pressDelay,\n ]\n );\n\n // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events\n const buttonGesture = useMemo(\n () =>\n Gesture.Native()\n .onBegin(() => {\n // Android sets BEGAN state on press down\n if (Platform.OS === 'android' || Platform.OS === 'macos') {\n isTouchPropagationAllowed.current = true;\n }\n })\n .onStart(() => {\n if (Platform.OS === 'web') {\n isTouchPropagationAllowed.current = true;\n }\n\n // iOS sets ACTIVE state on press down\n if (Platform.OS !== 'ios') {\n return;\n }\n\n if (deferredEventPayload.current) {\n isTouchPropagationAllowed.current = true;\n\n if (hasPassedBoundsChecks.current) {\n pressInHandler(deferredEventPayload.current);\n deferredEventPayload.current = null;\n } else {\n pressOutHandler(deferredEventPayload.current);\n isTouchPropagationAllowed.current = false;\n }\n\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n isTouchPropagationAllowed.current = true;\n return;\n }\n\n if (shouldPreventNativeEffects.current) {\n shouldPreventNativeEffects.current = false;\n return;\n }\n\n isTouchPropagationAllowed.current = true;\n }),\n [pressInHandler, pressOutHandler]\n );\n\n const appliedHitSlop = addInsets(\n normalizedHitSlop,\n normalizedPressRetentionOffset\n );\n\n const isPressableEnabled = disabled !== true;\n\n const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];\n\n for (const gesture of gestures) {\n gesture.enabled(isPressableEnabled);\n gesture.runOnJS(true);\n gesture.hitSlop(appliedHitSlop);\n gesture.shouldCancelWhenOutside(Platform.OS === 'web' ? false : true);\n }\n\n // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area\n buttonGesture.hitSlop(normalizedHitSlop);\n\n const gesture = Gesture.Simultaneous(...gestures);\n\n const defaultRippleColor = android_ripple ? undefined : 'transparent';\n\n // `cursor: 'pointer'` on `RNButton` crashes iOS\n const pointerStyle: StyleProp<ViewStyle> =\n Platform.OS === 'web' ? { cursor: 'pointer' } : {};\n\n const styleProp =\n typeof style === 'function' ? style({ pressed: pressedState }) : style;\n\n const childrenProp =\n typeof children === 'function'\n ? children({ pressed: pressedState })\n : children;\n\n return (\n <GestureDetector gesture={gesture}>\n <NativeButton\n {...remainingProps}\n ref={pressableRef}\n hitSlop={appliedHitSlop}\n enabled={isPressableEnabled}\n touchSoundDisabled={android_disableSound ?? undefined}\n rippleColor={processColor(android_ripple?.color ?? defaultRippleColor)}\n rippleRadius={android_ripple?.radius ?? undefined}\n style={[pointerStyle, styleProp]}>\n {childrenProp}\n {__DEV__ ? (\n <PressabilityDebugView color=\"red\" hitSlop={normalizedHitSlop} />\n ) : null}\n </NativeButton>\n </GestureDetector>\n );\n}\n"]}