react-native-gesture-handler 2.1.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/README.md +3 -2
  2. package/android/build.gradle +1 -1
  3. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +42 -11
  4. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +36 -2
  5. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +7 -4
  6. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +6 -4
  7. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +6 -4
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +8 -8
  9. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  10. package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  11. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  12. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
  13. package/lib/commonjs/handlers/gestures/GestureDetector.js +37 -13
  14. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  15. package/lib/commonjs/handlers/gestures/eventReceiver.js +1 -0
  16. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  17. package/lib/commonjs/index.js +0 -106
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/web/GestureHandler.js +4 -1
  20. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  21. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  22. package/lib/module/handlers/PanGestureHandler.js.map +1 -1
  23. package/lib/module/handlers/gestures/GestureDetector.js +35 -13
  24. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  25. package/lib/module/handlers/gestures/eventReceiver.js +1 -2
  26. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  27. package/lib/module/index.js +0 -11
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/web/GestureHandler.js +4 -1
  30. package/lib/module/web/GestureHandler.js.map +1 -1
  31. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -2
  32. package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -2
  33. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  34. package/lib/typescript/index.d.ts +11 -11
  35. package/lib/typescript/web/GestureHandler.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/src/handlers/LongPressGestureHandler.ts +2 -2
  38. package/src/handlers/PanGestureHandler.ts +2 -2
  39. package/src/handlers/gestures/GestureDetector.tsx +48 -11
  40. package/src/handlers/gestures/eventReceiver.ts +1 -1
  41. package/src/index.ts +11 -11
  42. package/src/web/GestureHandler.ts +7 -1
package/README.md CHANGED
@@ -47,7 +47,8 @@ Gesture handler library is licensed under [The MIT License](LICENSE).
47
47
 
48
48
  ## Credits
49
49
 
50
- This project is supported by amazing people from [Expo.io](https://expo.io) and [Software Mansion](https://swmansion.com)
50
+ This project has been build and is maintained thanks to the support from [Shopify](https://shopify.com), [Expo.io](https://expo.io) and [Software Mansion](https://swmansion.com)
51
51
 
52
+ [![shopify](https://avatars1.githubusercontent.com/u/8085?v=3&s=100 'Shopify.com')](https://shopify.com)
52
53
  [![expo](https://avatars2.githubusercontent.com/u/12504344?v=3&s=100 'Expo.io')](https://expo.io)
53
- [![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-gesture-handler-github 'Software Mansion')](https://swmansion.com)
54
+ [![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-reanimated-github 'Software Mansion')](https://swmansion.com)
@@ -27,7 +27,7 @@ def shouldUseCommonInterfaceFromReanimated() {
27
27
  def json = new JsonSlurper().parseText(inputFile.text)
28
28
  def reanimatedVersion = json.version as String
29
29
  def (major, minor, patch) = reanimatedVersion.tokenize('.')
30
- return Integer.parseInt(minor) >= 3
30
+ return Integer.parseInt(major) == 2 && Integer.parseInt(minor) >= 3
31
31
  } else {
32
32
  return false
33
33
  }
@@ -1,9 +1,14 @@
1
1
  package com.swmansion.gesturehandler
2
2
 
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import android.content.ContextWrapper
6
+ import android.graphics.Rect
3
7
  import android.view.MotionEvent
4
8
  import android.view.MotionEvent.PointerCoords
5
9
  import android.view.MotionEvent.PointerProperties
6
10
  import android.view.View
11
+ import android.view.Window
7
12
  import com.facebook.react.bridge.Arguments
8
13
  import com.facebook.react.bridge.UiThreadUtil
9
14
  import com.facebook.react.bridge.WritableArray
@@ -15,6 +20,7 @@ import java.util.*
15
20
  open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestureHandlerT>> {
16
21
  private val trackedPointerIDs = IntArray(MAX_POINTERS_COUNT)
17
22
  private var trackedPointersIDsCount = 0
23
+ private val windowOffset = IntArray(2) { 0 }
18
24
  var tag = 0
19
25
  var view: View? = null
20
26
  private set
@@ -67,14 +73,11 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
67
73
  protected inline fun applySelf(block: ConcreteGestureHandlerT.() -> Unit): ConcreteGestureHandlerT =
68
74
  self().apply { block() }
69
75
 
70
- // set and accessed only by the orchestrator
76
+ // properties set and accessed only by the orchestrator
71
77
  var activationIndex = 0
72
-
73
- // set and accessed only by the orchestrator
74
78
  var isActive = false
75
-
76
- // set and accessed only by the orchestrator
77
79
  var isAwaiting = false
80
+ var shouldResetProgress = false
78
81
 
79
82
  open fun dispatchStateChange(newState: Int, prevState: Int) {
80
83
  onTouchEventListener?.onStateChange(self(), newState, prevState)
@@ -158,6 +161,25 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
158
161
  state = STATE_UNDETERMINED
159
162
  this.view = view
160
163
  this.orchestrator = orchestrator
164
+
165
+ val decorView = getWindow(view?.context)?.decorView
166
+ if (decorView != null) {
167
+ val frame = Rect()
168
+ decorView.getWindowVisibleDisplayFrame(frame)
169
+ windowOffset[0] = frame.left
170
+ windowOffset[1] = frame.top
171
+ } else {
172
+ windowOffset[0] = 0
173
+ windowOffset[1] = 0
174
+ }
175
+ }
176
+
177
+ private fun getWindow(context: Context?): Window? {
178
+ if (context == null) return null
179
+ if (context is Activity) return context.window
180
+ if (context is ContextWrapper) return getWindow(context.baseContext)
181
+
182
+ return null
161
183
  }
162
184
 
163
185
  private fun findNextLocalPointerId(): Int {
@@ -341,8 +363,8 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
341
363
  pointerId,
342
364
  event.getX(event.actionIndex),
343
365
  event.getY(event.actionIndex),
344
- event.getX(event.actionIndex) + offsetX,
345
- event.getY(event.actionIndex) + offsetY,
366
+ event.getX(event.actionIndex) + offsetX - windowOffset[0],
367
+ event.getY(event.actionIndex) + offsetY - windowOffset[1],
346
368
  )
347
369
  trackedPointersCount++
348
370
  addChangedPointer(trackedPointers[pointerId]!!)
@@ -363,8 +385,8 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
363
385
  pointerId,
364
386
  event.getX(event.actionIndex),
365
387
  event.getY(event.actionIndex),
366
- event.getX(event.actionIndex) + offsetX,
367
- event.getY(event.actionIndex) + offsetY,
388
+ event.getX(event.actionIndex) + offsetX - windowOffset[0],
389
+ event.getY(event.actionIndex) + offsetY - windowOffset[1],
368
390
  )
369
391
  addChangedPointer(trackedPointers[pointerId]!!)
370
392
  trackedPointers[pointerId] = null
@@ -387,8 +409,8 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
387
409
  if (pointer.x != event.getX(i) || pointer.y != event.getY(i)) {
388
410
  pointer.x = event.getX(i)
389
411
  pointer.y = event.getY(i)
390
- pointer.absoluteX = event.getX(i) + offsetX
391
- pointer.absoluteY = event.getY(i) + offsetY
412
+ pointer.absoluteX = event.getX(i) + offsetX - windowOffset[0]
413
+ pointer.absoluteY = event.getY(i) + offsetY - windowOffset[1]
392
414
 
393
415
  addChangedPointer(pointer)
394
416
  pointersAdded++
@@ -617,6 +639,10 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
617
639
  }
618
640
  }
619
641
 
642
+ // responsible for resetting the state of handler upon activation (may be called more than once
643
+ // if the handler is waiting for failure of other one)
644
+ open fun resetProgress() {}
645
+
620
646
  protected open fun onHandle(event: MotionEvent) {
621
647
  moveToState(STATE_FAILED)
622
648
  }
@@ -651,6 +677,11 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
651
677
  val lastRelativePositionY: Float
652
678
  get() = lastAbsolutePositionY - lastEventOffsetY
653
679
 
680
+ val lastPositionInWindowX: Float
681
+ get() = lastAbsolutePositionX - windowOffset[0]
682
+ val lastPositionInWindowY: Float
683
+ get() = lastAbsolutePositionY - windowOffset[1]
684
+
654
685
  companion object {
655
686
  const val STATE_UNDETERMINED = 0
656
687
  const val STATE_FAILED = 1
@@ -142,8 +142,16 @@ class GestureHandlerOrchestrator(
142
142
  } else if (prevState == GestureHandler.STATE_ACTIVE || prevState == GestureHandler.STATE_END) {
143
143
  if (handler.isActive) {
144
144
  handler.dispatchStateChange(newState, prevState)
145
+ } else if (prevState == GestureHandler.STATE_ACTIVE) {
146
+ // handle edge case where handler awaiting for another one tries to activate but finishes
147
+ // before the other would not send state change event upon ending
148
+ handler.dispatchStateChange(newState, GestureHandler.STATE_BEGAN)
145
149
  }
146
- } else {
150
+ } else if (prevState != GestureHandler.STATE_UNDETERMINED || newState != GestureHandler.STATE_CANCELLED) {
151
+ // If handler is changing state from UNDETERMINED to CANCELLED, the state change event shouldn't
152
+ // be sent. Handler hasn't yet began so it may not be initialized which results in crashes.
153
+ // If it doesn't crash, there may be some weird behavior on JS side, as `onFinalize` will be
154
+ // called without calling `onBegin` first.
147
155
  handler.dispatchStateChange(newState, prevState)
148
156
  }
149
157
  handlingChangeSemaphore -= 1
@@ -155,6 +163,7 @@ class GestureHandlerOrchestrator(
155
163
  with(handler) {
156
164
  isAwaiting = false
157
165
  isActive = true
166
+ shouldResetProgress = true
158
167
  activationIndex = this@GestureHandlerOrchestrator.activationIndex++
159
168
  }
160
169
  var toCancelCount = 0
@@ -242,16 +251,41 @@ class GestureHandlerOrchestrator(
242
251
  // approach when we want to use pointer coordinates to calculate velocity or distance
243
252
  // for pinch so I don't know yet if we should transform or not...
244
253
  event.setLocation(coords[0], coords[1])
245
- if (handler.needsPointerData) {
254
+
255
+ // Touch events are sent before the handler itself has a chance to process them,
256
+ // mainly because `onTouchesUp` shoul be send befor gesture finishes. This means that
257
+ // the first `onTouchesDown` event is sent before a gesture begins, activation in
258
+ // callback for this event causes problems because the handler doesn't have a chance
259
+ // to initialize itself with starting values of pointer (in pan this causes translation
260
+ // to be equal to the coordinates of the pointer). The simplest solution is to send
261
+ // the first `onTouchesDown` event after the handler processes it and changes state
262
+ // to `BEGAN`.
263
+ if (handler.needsPointerData && handler.state != 0) {
246
264
  handler.updatePointerData(event)
247
265
  }
248
266
 
249
267
  if (!handler.isAwaiting || action != MotionEvent.ACTION_MOVE) {
268
+ val isFirstEvent = handler.state == 0
250
269
  handler.handle(event)
251
270
  if (handler.isActive) {
271
+ // After handler is done waiting for other one to fail its progress should be
272
+ // reset, otherwise there may be a visible jump in values sent by the handler.
273
+ // When handler is waiting it's already activated but the `isAwaiting` flag
274
+ // prevents it from receiving touch stream. When the flag is changed, the
275
+ // difference between this event and the last one may be large enough to be
276
+ // visible in interactions based on this gesture. This makes it consistent with
277
+ // the behavior on iOS.
278
+ if (handler.shouldResetProgress) {
279
+ handler.shouldResetProgress = false
280
+ handler.resetProgress()
281
+ }
252
282
  handler.dispatchHandlerUpdate(event)
253
283
  }
254
284
 
285
+ if (handler.needsPointerData && isFirstEvent) {
286
+ handler.updatePointerData(event)
287
+ }
288
+
255
289
  // if event was of type UP or POINTER_UP we request handler to stop tracking now that
256
290
  // the event has been dispatched
257
291
  if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
@@ -208,8 +208,7 @@ class PanGestureHandler(context: Context?) : GestureHandler<PanGestureHandler>()
208
208
  lastY = getLastPointerY(event, averageTouches)
209
209
  }
210
210
  if (state == STATE_UNDETERMINED && event.pointerCount >= minPointers) {
211
- startX = lastX
212
- startY = lastY
211
+ resetProgress()
213
212
  offsetX = 0f
214
213
  offsetY = 0f
215
214
  velocityX = 0f
@@ -253,8 +252,7 @@ class PanGestureHandler(context: Context?) : GestureHandler<PanGestureHandler>()
253
252
  override fun activate(force: Boolean) {
254
253
  // reset starting point if the handler has not yet activated
255
254
  if (state != STATE_ACTIVE) {
256
- startX = lastX
257
- startY = lastY
255
+ resetProgress()
258
256
  }
259
257
  super.activate(force)
260
258
  }
@@ -266,6 +264,11 @@ class PanGestureHandler(context: Context?) : GestureHandler<PanGestureHandler>()
266
264
  }
267
265
  }
268
266
 
267
+ override fun resetProgress() {
268
+ startX = lastX
269
+ startY = lastY
270
+ }
271
+
269
272
  companion object {
270
273
  private const val MIN_VALUE_IGNORE = Float.MAX_VALUE
271
274
  private const val MAX_VALUE_IGNORE = Float.MIN_VALUE
@@ -52,8 +52,7 @@ class PinchGestureHandler : GestureHandler<PinchGestureHandler>() {
52
52
  override fun onHandle(event: MotionEvent) {
53
53
  if (state == STATE_UNDETERMINED) {
54
54
  val context = view!!.context
55
- velocity = 0.0
56
- scale = 1.0
55
+ resetProgress()
57
56
  scaleGestureDetector = ScaleGestureDetector(context, gestureListener)
58
57
  val configuration = ViewConfiguration.get(context)
59
58
  spanSlop = configuration.scaledTouchSlop.toFloat()
@@ -74,14 +73,17 @@ class PinchGestureHandler : GestureHandler<PinchGestureHandler>() {
74
73
  override fun activate(force: Boolean) {
75
74
  // reset scale if the handler has not yet activated
76
75
  if (state != STATE_ACTIVE) {
77
- velocity = 0.0
78
- scale = 1.0
76
+ resetProgress()
79
77
  }
80
78
  super.activate(force)
81
79
  }
82
80
 
83
81
  override fun onReset() {
84
82
  scaleGestureDetector = null
83
+ resetProgress()
84
+ }
85
+
86
+ override fun resetProgress() {
85
87
  velocity = 0.0
86
88
  scale = 1.0
87
89
  }
@@ -43,8 +43,7 @@ class RotationGestureHandler : GestureHandler<RotationGestureHandler>() {
43
43
 
44
44
  override fun onHandle(event: MotionEvent) {
45
45
  if (state == STATE_UNDETERMINED) {
46
- velocity = 0.0
47
- rotation = 0.0
46
+ resetProgress()
48
47
  rotationGestureDetector = RotationGestureDetector(gestureListener)
49
48
  begin()
50
49
  }
@@ -61,14 +60,17 @@ class RotationGestureHandler : GestureHandler<RotationGestureHandler>() {
61
60
  override fun activate(force: Boolean) {
62
61
  // reset rotation if the handler has not yet activated
63
62
  if (state != STATE_ACTIVE) {
64
- rotation = 0.0
65
- velocity = 0.0
63
+ resetProgress()
66
64
  }
67
65
  super.activate(force)
68
66
  }
69
67
 
70
68
  override fun onReset() {
71
69
  rotationGestureDetector = null
70
+ resetProgress()
71
+ }
72
+
73
+ override fun resetProgress() {
72
74
  velocity = 0.0
73
75
  rotation = 0.0
74
76
  }
@@ -106,8 +106,8 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
106
106
  with(eventData) {
107
107
  putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
108
108
  putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
109
- putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionX).toDouble())
110
- putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionY).toDouble())
109
+ putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
110
+ putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
111
111
  }
112
112
  }
113
113
  }
@@ -135,8 +135,8 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
135
135
  with(eventData) {
136
136
  putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
137
137
  putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
138
- putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionX).toDouble())
139
- putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionY).toDouble())
138
+ putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
139
+ putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
140
140
  putInt("duration", handler.duration)
141
141
  }
142
142
  }
@@ -223,8 +223,8 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
223
223
  with(eventData) {
224
224
  putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
225
225
  putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
226
- putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionX).toDouble())
227
- putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionY).toDouble())
226
+ putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
227
+ putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
228
228
  putDouble("translationX", PixelUtil.toDIPFromPixel(handler.translationX).toDouble())
229
229
  putDouble("translationY", PixelUtil.toDIPFromPixel(handler.translationY).toDouble())
230
230
  putDouble("velocityX", PixelUtil.toDIPFromPixel(handler.velocityX).toDouble())
@@ -275,8 +275,8 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
275
275
  with(eventData) {
276
276
  putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
277
277
  putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
278
- putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionX).toDouble())
279
- putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastAbsolutePositionY).toDouble())
278
+ putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
279
+ putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
280
280
  }
281
281
  }
282
282
  }
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>RNGestureHandler-tvOS.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>1</integer>
11
+ </dict>
12
+ <key>RNGestureHandler.xcscheme_^#shared#^_</key>
13
+ <dict>
14
+ <key>orderHint</key>
15
+ <integer>0</integer>
16
+ </dict>
17
+ </dict>
18
+ </dict>
19
+ </plist>
@@ -1 +1 @@
1
- {"version":3,"sources":["LongPressGestureHandler.ts"],"names":["longPressGestureHandlerProps","LongPressGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;;AAkEP;AACO,MAAMC,uBAAuB,GAAG,4BAGrC;AACAC,EAAAA,IAAI,EAAE,yBADN;AAEAC,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGJ,4BAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAHqC,CAAhC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const longPressGestureHandlerProps = [\n 'minDurationMs',\n 'maxDist',\n] as const;\n\nexport type LongPressGestureHandlerEventPayload = {\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n x: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n y: number;\n\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the root view. It is recommended to use `absoluteX` instead of\n * `x` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the root view. It is recommended to use `absoluteY` instead of\n * `y` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Duration of the long press (time since the start of the event), expressed\n * in milliseconds.\n */\n duration: number;\n};\n\nexport interface LongPressGestureConfig {\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on\n * the corresponding view. The default value is 500.\n */\n minDurationMs?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a long press gesture. If the finger travels\n * further than the defined distance and the handler hasn't yet activated, it\n * will fail to recognize the gesture. The default value is 10.\n */\n maxDist?: number;\n}\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,\n LongPressGestureConfig {}\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: 'LongPressGestureHandler',\n allowedProps: [\n ...baseGestureHandlerProps,\n ...longPressGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}
1
+ {"version":3,"sources":["LongPressGestureHandler.ts"],"names":["longPressGestureHandlerProps","LongPressGestureHandler","name","allowedProps","baseGestureHandlerProps","config"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;;AAkEP;AACO,MAAMC,uBAAuB,GAAG,4BAGrC;AACAC,EAAAA,IAAI,EAAE,yBADN;AAEAC,EAAAA,YAAY,EAAE,CACZ,GAAGC,6CADS,EAEZ,GAAGJ,4BAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAHqC,CAAhC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const longPressGestureHandlerProps = [\n 'minDurationMs',\n 'maxDist',\n] as const;\n\nexport type LongPressGestureHandlerEventPayload = {\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n x: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n y: number;\n\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteX` instead of\n * `x` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteY` instead of\n * `y` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Duration of the long press (time since the start of the event), expressed\n * in milliseconds.\n */\n duration: number;\n};\n\nexport interface LongPressGestureConfig {\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on\n * the corresponding view. The default value is 500.\n */\n minDurationMs?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a long press gesture. If the finger travels\n * further than the defined distance and the handler hasn't yet activated, it\n * will fail to recognize the gesture. The default value is 10.\n */\n maxDist?: number;\n}\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,\n LongPressGestureConfig {}\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: 'LongPressGestureHandler',\n allowedProps: [\n ...baseGestureHandlerProps,\n ...longPressGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["PanGestureHandler.ts"],"names":["panGestureHandlerProps","panGestureHandlerCustomNativeProps","PanGestureHandler","name","allowedProps","baseGestureHandlerProps","config","transformProps","managePanProps","customNativeProps","validatePanGestureHandlerProps","props","Array","isArray","activeOffsetX","Error","activeOffsetY","failOffsetX","failOffsetY","minDist","transformPanGestureHandlerProps","res","undefined","activeOffsetXStart","activeOffsetXEnd","activeOffsetYStart","activeOffsetYEnd","failOffsetXStart","failOffsetXEnd","failOffsetYStart","failOffsetYEnd","__DEV__"],"mappings":";;;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,sBAAsB,GAAG,CACpC,eADoC,EAEpC,eAFoC,EAGpC,aAHoC,EAIpC,aAJoC,EAKpC,SALoC,EAMpC,aANoC,EAOpC,cAPoC,EAQpC,cARoC,EASpC,aAToC,EAUpC,aAVoC,EAWpC,YAXoC,EAYpC,gCAZoC,CAA/B;;AAeA,MAAMC,kCAAkC,GAAG,CAChD,oBADgD,EAEhD,kBAFgD,EAGhD,oBAHgD,EAIhD,kBAJgD,EAKhD,kBALgD,EAMhD,gBANgD,EAOhD,kBAPgD,EAQhD,gBARgD,CAA3C;;AAmKP;AACO,MAAMC,iBAAiB,GAAG,4BAG/B;AACAC,EAAAA,IAAI,EAAE,mBADN;AAEAC,EAAAA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AAwBG,KAAxB,EAAuD;AAC5D,MAAIoB,OAAJ,EAAa;AACXrB,IAAAA,8BAA8B,CAACC,KAAD,CAA9B;AACD;;AACD,SAAOS,+BAA+B,CAACT,KAAD,CAAtC;AACD","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const panGestureHandlerProps = [\n 'activeOffsetY',\n 'activeOffsetX',\n 'failOffsetY',\n 'failOffsetX',\n 'minDist',\n 'minVelocity',\n 'minVelocityX',\n 'minVelocityY',\n 'minPointers',\n 'maxPointers',\n 'avgTouches',\n 'enableTrackpadTwoFingerGesture',\n] as const;\n\nexport const panGestureHandlerCustomNativeProps = [\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'failOffsetYStart',\n 'failOffsetYEnd',\n 'failOffsetXStart',\n 'failOffsetXEnd',\n] as const;\n\nexport type PanGestureHandlerEventPayload = {\n /**\n * X coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the view\n * attached to the handler. Expressed in point units.\n */\n x: number;\n\n /**\n * Y coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the view\n * attached to the handler. Expressed in point units.\n */\n y: number;\n\n /**\n * X coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the root view.\n * The value is expressed in point units. It is recommended to use it instead\n * of `x` in cases when the original view can be transformed as an effect of\n * the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the root view.\n * The value is expressed in point units. It is recommended to use it instead\n * of `y` in cases when the original view can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Translation of the pan gesture along X axis accumulated over the time of\n * the gesture. The value is expressed in the point units.\n */\n translationX: number;\n\n /**\n * Translation of the pan gesture along Y axis accumulated over the time of\n * the gesture. The value is expressed in the point units.\n */\n translationY: number;\n\n /**\n * Velocity of the pan gesture along the X axis in the current moment. The\n * value is expressed in point units per second.\n */\n velocityX: number;\n\n /**\n * Velocity of the pan gesture along the Y axis in the current moment. The\n * value is expressed in point units per second.\n */\n velocityY: number;\n};\n\ninterface CommonPanProperties {\n /**\n * Minimum distance the finger (or multiple finger) need to travel before the\n * handler activates. Expressed in points.\n */\n minDist?: number;\n\n /**\n * Android only.\n */\n avgTouches?: boolean;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * enableTrackpadTwoFingerGesture swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * A number of fingers that is required to be placed before handler can\n * activate. Should be a higher or equal to 0 integer.\n */\n minPointers?: number;\n\n /**\n * When the given number of fingers is placed on the screen and handler hasn't\n * yet activated it will fail recognizing the gesture. Should be a higher or\n * equal to 0 integer.\n */\n maxPointers?: number;\n\n minVelocity?: number;\n minVelocityX?: number;\n minVelocityY?: number;\n}\n\nexport interface PanGestureConfig extends CommonPanProperties {\n activeOffsetYStart?: number;\n activeOffsetYEnd?: number;\n activeOffsetXStart?: number;\n activeOffsetXEnd?: number;\n failOffsetYStart?: number;\n failOffsetYEnd?: number;\n failOffsetXStart?: number;\n failOffsetXEnd?: number;\n}\n\nexport interface PanGestureHandlerProps\n extends BaseGestureHandlerProps<PanGestureHandlerEventPayload>,\n CommonPanProperties {\n /**\n * Range along X axis (in points) where fingers travels without activation of\n * handler. Moving outside of this range implies activation of handler. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n activeOffsetY?: number | number[];\n\n /**\n * Range along X axis (in points) where fingers travels without activation of\n * handler. Moving outside of this range implies activation of handler. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n activeOffsetX?: number | number[];\n\n /**\n * When the finger moves outside this range (in points) along Y axis and\n * handler hasn't yet activated it will fail recognizing the gesture. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n failOffsetY?: number | number[];\n\n /**\n * When the finger moves outside this range (in points) along X axis and\n * handler hasn't yet activated it will fail recognizing the gesture. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n failOffsetX?: number | number[];\n}\n\nexport type PanGestureHandler = typeof PanGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const PanGestureHandler = createHandler<\n PanGestureHandlerProps,\n PanGestureHandlerEventPayload\n>({\n name: 'PanGestureHandler',\n allowedProps: [\n ...baseGestureHandlerProps,\n ...panGestureHandlerProps,\n ] as const,\n config: {},\n transformProps: managePanProps,\n customNativeProps: panGestureHandlerCustomNativeProps,\n});\n\nfunction validatePanGestureHandlerProps(props: PanGestureHandlerProps) {\n if (\n Array.isArray(props.activeOffsetX) &&\n (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.activeOffsetY) &&\n (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetX) &&\n (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetY) &&\n (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (props.minDist && (props.failOffsetX || props.failOffsetY)) {\n throw new Error(\n `It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`\n );\n }\n\n if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {\n throw new Error(\n `It is not supported to use minDist with activeOffsetX or activeOffsetY`\n );\n }\n}\n\nfunction transformPanGestureHandlerProps(props: PanGestureHandlerProps) {\n type InternalPanGHKeys =\n | 'activeOffsetXStart'\n | 'activeOffsetXEnd'\n | 'failOffsetXStart'\n | 'failOffsetXEnd'\n | 'activeOffsetYStart'\n | 'activeOffsetYEnd'\n | 'failOffsetYStart'\n | 'failOffsetYEnd';\n type PanGestureHandlerInternalProps = PanGestureHandlerProps &\n Partial<Record<InternalPanGHKeys, number>>;\n\n const res: PanGestureHandlerInternalProps = { ...props };\n\n if (props.activeOffsetX !== undefined) {\n delete res.activeOffsetX;\n if (Array.isArray(props.activeOffsetX)) {\n res.activeOffsetXStart = props.activeOffsetX[0];\n res.activeOffsetXEnd = props.activeOffsetX[1];\n } else if (props.activeOffsetX < 0) {\n res.activeOffsetXStart = props.activeOffsetX;\n } else {\n res.activeOffsetXEnd = props.activeOffsetX;\n }\n }\n\n if (props.activeOffsetY !== undefined) {\n delete res.activeOffsetY;\n if (Array.isArray(props.activeOffsetY)) {\n res.activeOffsetYStart = props.activeOffsetY[0];\n res.activeOffsetYEnd = props.activeOffsetY[1];\n } else if (props.activeOffsetY < 0) {\n res.activeOffsetYStart = props.activeOffsetY;\n } else {\n res.activeOffsetYEnd = props.activeOffsetY;\n }\n }\n\n if (props.failOffsetX !== undefined) {\n delete res.failOffsetX;\n if (Array.isArray(props.failOffsetX)) {\n res.failOffsetXStart = props.failOffsetX[0];\n res.failOffsetXEnd = props.failOffsetX[1];\n } else if (props.failOffsetX < 0) {\n res.failOffsetXStart = props.failOffsetX;\n } else {\n res.failOffsetXEnd = props.failOffsetX;\n }\n }\n\n if (props.failOffsetY !== undefined) {\n delete res.failOffsetY;\n if (Array.isArray(props.failOffsetY)) {\n res.failOffsetYStart = props.failOffsetY[0];\n res.failOffsetYEnd = props.failOffsetY[1];\n } else if (props.failOffsetY < 0) {\n res.failOffsetYStart = props.failOffsetY;\n } else {\n res.failOffsetYEnd = props.failOffsetY;\n }\n }\n\n return res;\n}\n\nexport function managePanProps(props: PanGestureHandlerProps) {\n if (__DEV__) {\n validatePanGestureHandlerProps(props);\n }\n return transformPanGestureHandlerProps(props);\n}\n"]}
1
+ {"version":3,"sources":["PanGestureHandler.ts"],"names":["panGestureHandlerProps","panGestureHandlerCustomNativeProps","PanGestureHandler","name","allowedProps","baseGestureHandlerProps","config","transformProps","managePanProps","customNativeProps","validatePanGestureHandlerProps","props","Array","isArray","activeOffsetX","Error","activeOffsetY","failOffsetX","failOffsetY","minDist","transformPanGestureHandlerProps","res","undefined","activeOffsetXStart","activeOffsetXEnd","activeOffsetYStart","activeOffsetYEnd","failOffsetXStart","failOffsetXEnd","failOffsetYStart","failOffsetYEnd","__DEV__"],"mappings":";;;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,sBAAsB,GAAG,CACpC,eADoC,EAEpC,eAFoC,EAGpC,aAHoC,EAIpC,aAJoC,EAKpC,SALoC,EAMpC,aANoC,EAOpC,cAPoC,EAQpC,cARoC,EASpC,aAToC,EAUpC,aAVoC,EAWpC,YAXoC,EAYpC,gCAZoC,CAA/B;;AAeA,MAAMC,kCAAkC,GAAG,CAChD,oBADgD,EAEhD,kBAFgD,EAGhD,oBAHgD,EAIhD,kBAJgD,EAKhD,kBALgD,EAMhD,gBANgD,EAOhD,kBAPgD,EAQhD,gBARgD,CAA3C;;AAmKP;AACO,MAAMC,iBAA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,WAA3B;AACD;AACF;;AAED,SAAOG,GAAP;AACD;;AAEM,SAASb,cAAT,CAAwBG,KAAxB,EAAuD;AAC5D,MAAIoB,OAAJ,EAAa;AACXrB,IAAAA,8BAA8B,CAACC,KAAD,CAA9B;AACD;;AACD,SAAOS,+BAA+B,CAACT,KAAD,CAAtC;AACD","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const panGestureHandlerProps = [\n 'activeOffsetY',\n 'activeOffsetX',\n 'failOffsetY',\n 'failOffsetX',\n 'minDist',\n 'minVelocity',\n 'minVelocityX',\n 'minVelocityY',\n 'minPointers',\n 'maxPointers',\n 'avgTouches',\n 'enableTrackpadTwoFingerGesture',\n] as const;\n\nexport const panGestureHandlerCustomNativeProps = [\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'failOffsetYStart',\n 'failOffsetYEnd',\n 'failOffsetXStart',\n 'failOffsetXEnd',\n] as const;\n\nexport type PanGestureHandlerEventPayload = {\n /**\n * X coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the view\n * attached to the handler. Expressed in point units.\n */\n x: number;\n\n /**\n * Y coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the view\n * attached to the handler. Expressed in point units.\n */\n y: number;\n\n /**\n * X coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the window.\n * The value is expressed in point units. It is recommended to use it instead\n * of `x` in cases when the original view can be transformed as an effect of\n * the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate of the current position of the pointer (finger or a leading\n * pointer when there are multiple fingers placed) relative to the window.\n * The value is expressed in point units. It is recommended to use it instead\n * of `y` in cases when the original view can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Translation of the pan gesture along X axis accumulated over the time of\n * the gesture. The value is expressed in the point units.\n */\n translationX: number;\n\n /**\n * Translation of the pan gesture along Y axis accumulated over the time of\n * the gesture. The value is expressed in the point units.\n */\n translationY: number;\n\n /**\n * Velocity of the pan gesture along the X axis in the current moment. The\n * value is expressed in point units per second.\n */\n velocityX: number;\n\n /**\n * Velocity of the pan gesture along the Y axis in the current moment. The\n * value is expressed in point units per second.\n */\n velocityY: number;\n};\n\ninterface CommonPanProperties {\n /**\n * Minimum distance the finger (or multiple finger) need to travel before the\n * handler activates. Expressed in points.\n */\n minDist?: number;\n\n /**\n * Android only.\n */\n avgTouches?: boolean;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * enableTrackpadTwoFingerGesture swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * A number of fingers that is required to be placed before handler can\n * activate. Should be a higher or equal to 0 integer.\n */\n minPointers?: number;\n\n /**\n * When the given number of fingers is placed on the screen and handler hasn't\n * yet activated it will fail recognizing the gesture. Should be a higher or\n * equal to 0 integer.\n */\n maxPointers?: number;\n\n minVelocity?: number;\n minVelocityX?: number;\n minVelocityY?: number;\n}\n\nexport interface PanGestureConfig extends CommonPanProperties {\n activeOffsetYStart?: number;\n activeOffsetYEnd?: number;\n activeOffsetXStart?: number;\n activeOffsetXEnd?: number;\n failOffsetYStart?: number;\n failOffsetYEnd?: number;\n failOffsetXStart?: number;\n failOffsetXEnd?: number;\n}\n\nexport interface PanGestureHandlerProps\n extends BaseGestureHandlerProps<PanGestureHandlerEventPayload>,\n CommonPanProperties {\n /**\n * Range along X axis (in points) where fingers travels without activation of\n * handler. Moving outside of this range implies activation of handler. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n activeOffsetY?: number | number[];\n\n /**\n * Range along X axis (in points) where fingers travels without activation of\n * handler. Moving outside of this range implies activation of handler. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n activeOffsetX?: number | number[];\n\n /**\n * When the finger moves outside this range (in points) along Y axis and\n * handler hasn't yet activated it will fail recognizing the gesture. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n failOffsetY?: number | number[];\n\n /**\n * When the finger moves outside this range (in points) along X axis and\n * handler hasn't yet activated it will fail recognizing the gesture. Range\n * can be given as an array or a single number. If range is set as an array,\n * first value must be lower or equal to 0, a the second one higher or equal\n * to 0. If only one number `p` is given a range of `(-inf, p)` will be used\n * if `p` is higher or equal to 0 and `(-p, inf)` otherwise.\n */\n failOffsetX?: number | number[];\n}\n\nexport type PanGestureHandler = typeof PanGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const PanGestureHandler = createHandler<\n PanGestureHandlerProps,\n PanGestureHandlerEventPayload\n>({\n name: 'PanGestureHandler',\n allowedProps: [\n ...baseGestureHandlerProps,\n ...panGestureHandlerProps,\n ] as const,\n config: {},\n transformProps: managePanProps,\n customNativeProps: panGestureHandlerCustomNativeProps,\n});\n\nfunction validatePanGestureHandlerProps(props: PanGestureHandlerProps) {\n if (\n Array.isArray(props.activeOffsetX) &&\n (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.activeOffsetY) &&\n (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of activeOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetX) &&\n (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetX should be negative, a the second one should be positive`\n );\n }\n\n if (\n Array.isArray(props.failOffsetY) &&\n (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)\n ) {\n throw new Error(\n `First element of failOffsetY should be negative, a the second one should be positive`\n );\n }\n\n if (props.minDist && (props.failOffsetX || props.failOffsetY)) {\n throw new Error(\n `It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`\n );\n }\n\n if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {\n throw new Error(\n `It is not supported to use minDist with activeOffsetX or activeOffsetY`\n );\n }\n}\n\nfunction transformPanGestureHandlerProps(props: PanGestureHandlerProps) {\n type InternalPanGHKeys =\n | 'activeOffsetXStart'\n | 'activeOffsetXEnd'\n | 'failOffsetXStart'\n | 'failOffsetXEnd'\n | 'activeOffsetYStart'\n | 'activeOffsetYEnd'\n | 'failOffsetYStart'\n | 'failOffsetYEnd';\n type PanGestureHandlerInternalProps = PanGestureHandlerProps &\n Partial<Record<InternalPanGHKeys, number>>;\n\n const res: PanGestureHandlerInternalProps = { ...props };\n\n if (props.activeOffsetX !== undefined) {\n delete res.activeOffsetX;\n if (Array.isArray(props.activeOffsetX)) {\n res.activeOffsetXStart = props.activeOffsetX[0];\n res.activeOffsetXEnd = props.activeOffsetX[1];\n } else if (props.activeOffsetX < 0) {\n res.activeOffsetXStart = props.activeOffsetX;\n } else {\n res.activeOffsetXEnd = props.activeOffsetX;\n }\n }\n\n if (props.activeOffsetY !== undefined) {\n delete res.activeOffsetY;\n if (Array.isArray(props.activeOffsetY)) {\n res.activeOffsetYStart = props.activeOffsetY[0];\n res.activeOffsetYEnd = props.activeOffsetY[1];\n } else if (props.activeOffsetY < 0) {\n res.activeOffsetYStart = props.activeOffsetY;\n } else {\n res.activeOffsetYEnd = props.activeOffsetY;\n }\n }\n\n if (props.failOffsetX !== undefined) {\n delete res.failOffsetX;\n if (Array.isArray(props.failOffsetX)) {\n res.failOffsetXStart = props.failOffsetX[0];\n res.failOffsetXEnd = props.failOffsetX[1];\n } else if (props.failOffsetX < 0) {\n res.failOffsetXStart = props.failOffsetX;\n } else {\n res.failOffsetXEnd = props.failOffsetX;\n }\n }\n\n if (props.failOffsetY !== undefined) {\n delete res.failOffsetY;\n if (Array.isArray(props.failOffsetY)) {\n res.failOffsetYStart = props.failOffsetY[0];\n res.failOffsetYEnd = props.failOffsetY[1];\n } else if (props.failOffsetY < 0) {\n res.failOffsetYStart = props.failOffsetY;\n } else {\n res.failOffsetYEnd = props.failOffsetY;\n }\n }\n\n return res;\n}\n\nexport function managePanProps(props: PanGestureHandlerProps) {\n if (__DEV__) {\n validatePanGestureHandlerProps(props);\n }\n return transformPanGestureHandlerProps(props);\n}\n"]}
@@ -33,6 +33,10 @@ var _State = require("../../State");
33
33
 
34
34
  var _EventType = require("../../EventType");
35
35
 
36
+ var _reactNative = require("react-native");
37
+
38
+ var _eventReceiver = require("./eventReceiver");
39
+
36
40
  var _Reanimated$default$c, _Reanimated$default;
37
41
 
38
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -76,7 +80,8 @@ function attachHandlers({
76
80
  gestureConfig,
77
81
  gesture,
78
82
  viewTag,
79
- useAnimated
83
+ useAnimated,
84
+ webEventHandlersRef
80
85
  }) {
81
86
  if (!preparedGesture.firstExecution) {
82
87
  gestureConfig === null || gestureConfig === void 0 ? void 0 : gestureConfig.initialize();
@@ -119,8 +124,13 @@ function attachHandlers({
119
124
  preparedGesture.config = gesture;
120
125
 
121
126
  for (const gesture of preparedGesture.config) {
122
- _RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, !useAnimated // send direct events when using animatedGesture, device events otherwise
123
- );
127
+ if (_reactNative.Platform.OS === 'web') {
128
+ _RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, !useAnimated, // send direct events when using animatedGesture, device events otherwise
129
+ webEventHandlersRef);
130
+ } else {
131
+ _RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, !useAnimated // send direct events when using animatedGesture, device events otherwise
132
+ );
133
+ }
124
134
  }
125
135
 
126
136
  if (preparedGesture.animatedHandlers) {
@@ -132,9 +142,13 @@ function updateHandlers(preparedGesture, gestureConfig, gesture) {
132
142
  gestureConfig === null || gestureConfig === void 0 ? void 0 : gestureConfig.prepare();
133
143
 
134
144
  for (let i = 0; i < gesture.length; i++) {
135
- const handler = preparedGesture.config[i];
136
- gesture[i].handlerTag = handler.handlerTag;
137
- gesture[i].handlers.handlerTag = handler.handlerTag;
145
+ const handler = preparedGesture.config[i]; // only update handlerTag when it's actually different, it may be the same
146
+ // if gesture config object is wrapped with useMemo
147
+
148
+ if (gesture[i].handlerTag !== handler.handlerTag) {
149
+ gesture[i].handlerTag = handler.handlerTag;
150
+ gesture[i].handlers.handlerTag = handler.handlerTag;
151
+ }
138
152
  } // use setImmediate to extract handlerTags, because when it's ran, all refs should be updated
139
153
  // and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
140
154
  // in case of external relations)
@@ -145,7 +159,6 @@ function updateHandlers(preparedGesture, gestureConfig, gesture) {
145
159
  const handler = preparedGesture.config[i];
146
160
  handler.config = gesture[i].config;
147
161
  handler.handlers = gesture[i].handlers;
148
- handler.handlers.handlerTag = handler.handlerTag;
149
162
  const requireToFail = extractValidHandlerTags(handler.config.requireToFail);
150
163
  const simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
151
164
 
@@ -177,7 +190,7 @@ function needsToReattach(preparedGesture, gesture) {
177
190
  return false;
178
191
  }
179
192
 
180
- function useAnimatedGesture(preparedGesture) {
193
+ function useAnimatedGesture(preparedGesture, needsRebuild) {
181
194
  if (!_reanimatedWrapper.Reanimated) {
182
195
  return;
183
196
  }
@@ -330,7 +343,7 @@ function useAnimatedGesture(preparedGesture) {
330
343
  }; // eslint-disable-next-line react-hooks/rules-of-hooks
331
344
 
332
345
 
333
- const event = _reanimatedWrapper.Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], true);
346
+ const event = _reanimatedWrapper.Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], needsRebuild);
334
347
 
335
348
  preparedGesture.animatedEventHandler = event;
336
349
  preparedGesture.animatedHandlers = sharedHandlersCallbacks;
@@ -344,6 +357,11 @@ const GestureDetector = props => {
344
357
  const useAnimated = gesture.find(gesture => gesture.handlers.isWorklet.reduce((prev, current) => prev || current)) != null;
345
358
  const viewRef = (0, _react.useRef)(null);
346
359
  const firstRenderRef = (0, _react.useRef)(true);
360
+ const webEventHandlersRef = (0, _react.useRef)({
361
+ onGestureHandlerEvent: e => {
362
+ (0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
363
+ }
364
+ });
347
365
 
348
366
  const preparedGesture = _react.default.useRef({
349
367
  config: gesture,
@@ -355,7 +373,11 @@ const GestureDetector = props => {
355
373
 
356
374
  if (useAnimated !== preparedGesture.useAnimated) {
357
375
  throw new Error('You cannot change whether you are using gesture or animatedGesture while the app is running');
358
- }
376
+ } // Reanimated event should be rebuilt only when gestures are reattached, otherwise
377
+ // config update will be enough as all necessary items are stored in shared values anyway
378
+
379
+
380
+ const needsToRebuildReanimatedEvent = preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture);
359
381
 
360
382
  if (preparedGesture.firstExecution) {
361
383
  var _gestureConfig$initia;
@@ -367,7 +389,7 @@ const GestureDetector = props => {
367
389
  // Whether animatedGesture or gesture is used shouldn't change
368
390
  // during while an app is running
369
391
  // eslint-disable-next-line react-hooks/rules-of-hooks
370
- useAnimatedGesture(preparedGesture);
392
+ useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
371
393
  }
372
394
 
373
395
  (0, _react.useEffect)(() => {
@@ -378,7 +400,8 @@ const GestureDetector = props => {
378
400
  gestureConfig,
379
401
  gesture,
380
402
  viewTag,
381
- useAnimated
403
+ useAnimated,
404
+ webEventHandlersRef
382
405
  });
383
406
  return () => {
384
407
  dropHandlers(preparedGesture);
@@ -395,7 +418,8 @@ const GestureDetector = props => {
395
418
  gestureConfig,
396
419
  gesture,
397
420
  viewTag,
398
- useAnimated
421
+ useAnimated,
422
+ webEventHandlersRef
399
423
  });
400
424
  } else {
401
425
  updateHandlers(preparedGesture, gestureConfig, gesture);