react-native-gesture-handler 3.0.0-beta.1 → 3.0.0-nightly-20260210-746564b1e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ import android.view.ViewGroup
8
8
  import android.widget.EditText
9
9
  import com.facebook.react.uimanager.ReactCompoundView
10
10
  import com.facebook.react.uimanager.RootView
11
+ import com.swmansion.gesturehandler.react.RNGestureHandlerDetectorView
11
12
  import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
12
13
  import com.swmansion.gesturehandler.react.RNGestureHandlerRootView
13
14
  import com.swmansion.gesturehandler.react.isHoverAction
@@ -745,9 +746,12 @@ class GestureHandlerOrchestrator(
745
746
 
746
747
  // TODO: this is not an ideal solution as we only consider ViewGroups that has no background set
747
748
  // TODO: ideally we should determine the pixel color under the given coordinates and return
748
- // false if the color is transparent
749
- val isLeafOrTransparent = view !is ViewGroup || view.getBackground() != null
750
- return isLeafOrTransparent && isTransformedTouchPointInView(coords[0], coords[1], view)
749
+ val isLeaf = view !is ViewGroup
750
+ val isNotTransparent = view.getBackground() != null
751
+ val isDirectDetectorChild = view.parent is RNGestureHandlerDetectorView
752
+ val isPointInView = isTransformedTouchPointInView(coords[0], coords[1], view)
753
+
754
+ return (isLeaf || isNotTransparent || isDirectDetectorChild) && isPointInView
751
755
  }
752
756
 
753
757
  fun transformPointToChildViewCoords(x: Float, y: Float, parent: ViewGroup, child: View, outLocalPoint: PointF) {
@@ -37,6 +37,43 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
37
37
  attachHandlers(newHandlers)
38
38
  }
39
39
 
40
+ override fun onAttachedToWindow() {
41
+ super.onAttachedToWindow()
42
+
43
+ if (moduleId != -1) {
44
+ handlersToAttach?.let {
45
+ attachHandlers(it)
46
+ }
47
+
48
+ virtualChildrenToAttach?.let {
49
+ attachVirtualChildren(it)
50
+ }
51
+
52
+ handlersToAttach = null
53
+ virtualChildrenToAttach = null
54
+ }
55
+ }
56
+
57
+ override fun onDetachedFromWindow() {
58
+ if (attachedHandlers.isNotEmpty()) {
59
+ handlersToAttach = attachedHandlers.toMutableList().also {
60
+ it.addAll(handlersToAttach ?: emptyList())
61
+ }
62
+ }
63
+
64
+ if (attachedVirtualHandlers.isNotEmpty()) {
65
+ virtualChildrenToAttach = attachedVirtualHandlers.map {
66
+ VirtualChildren(it.value.toList(), it.key)
67
+ }.toMutableList().also {
68
+ it.addAll(virtualChildrenToAttach ?: emptyList())
69
+ }
70
+ }
71
+
72
+ detachAllHandlers()
73
+
74
+ super.onDetachedFromWindow()
75
+ }
76
+
40
77
  fun setModuleId(id: Int) {
41
78
  assert(this.moduleId == -1) { "Tried to change moduleId of a native detector" }
42
79
 
@@ -109,7 +146,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
109
146
  }
110
147
 
111
148
  for (tag in handlersToDetach) {
112
- registry.detachHandler(tag)
149
+ registry.detachHandlerFromHostDetector(tag, this)
113
150
  nativeHandlers.remove(tag)
114
151
  attachedHandlers.remove(tag)
115
152
  }
@@ -134,7 +171,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
134
171
 
135
172
  for (child in virtualChildrenToDetach) {
136
173
  for (tag in attachedVirtualHandlers[child]!!) {
137
- registry.detachHandler(tag)
174
+ registry.detachHandlerFromHostDetector(tag, this)
138
175
  }
139
176
  attachedVirtualHandlers.remove(tag)
140
177
  }
@@ -182,7 +219,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
182
219
  ?: throw Exception("Tried to access a non-existent registry")
183
220
 
184
221
  for (tag in nativeHandlers) {
185
- registry.detachHandler(tag)
222
+ registry.detachHandlerFromHostDetector(tag, this)
186
223
  attachedHandlers.remove(tag)
187
224
  }
188
225
  }
@@ -192,18 +229,18 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
192
229
  eventDispatcher?.dispatchEvent(event)
193
230
  }
194
231
 
195
- fun onViewDrop() {
232
+ fun detachAllHandlers() {
196
233
  val registry = RNGestureHandlerModule.registries[moduleId]
197
234
  ?: throw Exception("Tried to access a non-existent registry")
198
235
 
199
236
  for (tag in attachedHandlers.toMutableSet()) {
200
- registry.detachHandler(tag)
237
+ registry.detachHandlerFromHostDetector(tag, this)
201
238
  attachedHandlers.remove(tag)
202
239
  }
203
240
 
204
241
  for (child in attachedVirtualHandlers) {
205
242
  for (tag in child.value) {
206
- registry.detachHandler(tag)
243
+ registry.detachHandlerFromHostDetector(tag, this)
207
244
  }
208
245
  child.value.clear()
209
246
  }
@@ -43,7 +43,7 @@ class RNGestureHandlerDetectorViewManager :
43
43
  }
44
44
 
45
45
  override fun onDropViewInstance(view: RNGestureHandlerDetectorView) {
46
- view.onViewDrop()
46
+ view.detachAllHandlers()
47
47
  super.onDropViewInstance(view)
48
48
  }
49
49
 
@@ -78,8 +78,9 @@ class RNGestureHandlerRegistry : GestureHandlerRegistry {
78
78
  }
79
79
 
80
80
  @Synchronized
81
- fun detachHandler(handlerTag: Int) {
81
+ fun detachHandlerFromHostDetector(handlerTag: Int, hostDetectorView: RNGestureHandlerDetectorView?) {
82
82
  handlers[handlerTag]?.let {
83
+ if (it.hostDetectorView != hostDetectorView) return
83
84
  detachHandlerInternal(it)
84
85
  }
85
86
  }
@@ -47,16 +47,17 @@
47
47
  {
48
48
  if (newWindow == nil) {
49
49
  RNGestureHandlerManager *handlerManager = [RNGestureHandlerModule handlerManagerForModuleId:_moduleId];
50
- react_native_assert(handlerManager != nullptr && "Tried to access a non-existent handler manager")
51
- const auto &props = *std::static_pointer_cast<const RNGestureHandlerDetectorProps>(_props);
50
+ react_native_assert(handlerManager != nullptr && "Tried to access a non-existent handler manager");
51
+
52
+ const auto &props = *std::static_pointer_cast<const RNGestureHandlerDetectorProps>(_props);
52
53
 
53
54
  for (const auto handler : props.handlerTags) {
54
55
  NSNumber *handlerTag = [NSNumber numberWithInt:handler];
55
- [handlerManager.registry detachHandlerWithTag:handlerTag];
56
+ [handlerManager.registry detachHandlerWithTag:handlerTag fromHostDetector:self];
56
57
  }
57
58
  for (const auto &child : _attachedVirtualHandlers) {
58
59
  for (id handlerTag : child.second) {
59
- [handlerManager.registry detachHandlerWithTag:handlerTag];
60
+ [handlerManager.registry detachHandlerWithTag:handlerTag fromHostDetector:self];
60
61
  }
61
62
  }
62
63
  _attachedVirtualHandlers.clear();
@@ -190,9 +191,9 @@
190
191
  attachedHandlers:(NSMutableSet *)attachedHandlers
191
192
  {
192
193
  RNGestureHandlerManager *handlerManager = [RNGestureHandlerModule handlerManagerForModuleId:_moduleId];
193
- react_native_assert(handlerManager != nullptr && "Tried to access a non-existent handler manager")
194
+ react_native_assert(handlerManager != nullptr && "Tried to access a non-existent handler manager");
194
195
 
195
- NSMutableSet *handlersToDetach = [attachedHandlers mutableCopy];
196
+ NSMutableSet *handlersToDetach = [attachedHandlers mutableCopy];
196
197
 
197
198
  for (const int tag : handlerTags) {
198
199
  [handlersToDetach removeObject:@(tag)];
@@ -231,7 +232,7 @@
231
232
  }
232
233
 
233
234
  for (const id tag : handlersToDetach) {
234
- [handlerManager.registry detachHandlerWithTag:tag];
235
+ [handlerManager.registry detachHandlerWithTag:tag fromHostDetector:self];
235
236
  [attachedHandlers removeObject:tag];
236
237
  [_nativeHandlers removeObject:tag];
237
238
  }
@@ -262,9 +263,9 @@
262
263
  - (void)updateVirtualChildren:(const std::vector<RNGestureHandlerDetectorVirtualChildrenStruct> &)virtualChildren
263
264
  {
264
265
  RNGestureHandlerManager *handlerManager = [RNGestureHandlerModule handlerManagerForModuleId:_moduleId];
265
- react_native_assert(handlerManager != nullptr && "Tried to access a non-existent handler manager")
266
+ react_native_assert(handlerManager != nullptr && "Tried to access a non-existent handler manager");
266
267
 
267
- NSMutableSet *virtualChildrenToDetach = [NSMutableSet set];
268
+ NSMutableSet *virtualChildrenToDetach = [NSMutableSet set];
268
269
  for (const auto &child : _attachedVirtualHandlers) {
269
270
  [virtualChildrenToDetach addObject:@(child.first)];
270
271
  }
@@ -275,7 +276,7 @@
275
276
 
276
277
  for (const NSNumber *tag : virtualChildrenToDetach) {
277
278
  for (id handlerTag : _attachedVirtualHandlers[tag.intValue]) {
278
- [handlerManager.registry detachHandlerWithTag:handlerTag];
279
+ [handlerManager.registry detachHandlerWithTag:handlerTag fromHostDetector:self];
279
280
  }
280
281
  _attachedVirtualHandlers.erase(tag.intValue);
281
282
  }
@@ -325,7 +326,7 @@
325
326
  RNGestureHandlerManager *handlerManager = [RNGestureHandlerModule handlerManagerForModuleId:_moduleId];
326
327
 
327
328
  for (NSNumber *handlerTag in _nativeHandlers) {
328
- [[handlerManager registry] detachHandlerWithTag:handlerTag];
329
+ [[handlerManager registry] detachHandlerWithTag:handlerTag fromHostDetector:self];
329
330
  [_attachedHandlers removeObject:handlerTag];
330
331
  }
331
332
  }
@@ -17,6 +17,7 @@
17
17
  withActionType:(RNGestureHandlerActionType)actionType
18
18
  withHostDetector:(nullable RNGHUIView *)hostDetector;
19
19
  - (void)detachHandlerWithTag:(nonnull NSNumber *)handlerTag;
20
+ - (void)detachHandlerWithTag:(nonnull NSNumber *)handlerTag fromHostDetector:(nonnull RNGHUIView *)hostDetectorView;
20
21
  - (void)dropHandlerWithTag:(nonnull NSNumber *)handlerTag;
21
22
  - (void)dropAllHandlers;
22
23
 
@@ -48,9 +48,11 @@
48
48
  }
49
49
  }
50
50
 
51
- - (void)detachHandlerWithTag:(NSNumber *)handlerTag
51
+ - (void)detachHandlerWithTag:(NSNumber *)handlerTag fromHostDetector:(RNGHUIView *)hostDetectorView
52
52
  {
53
53
  RNGestureHandler *handler = _handlers[handlerTag];
54
+ if (handler.hostDetectorView != hostDetectorView)
55
+ return;
54
56
  [handler unbindFromView];
55
57
  }
56
58
 
@@ -60,6 +60,10 @@ function useGesture(type, config) {
60
60
  }), [handlerTag, type, config, jsEventHandler, reanimatedEventHandler, animatedEventHandler, gestureRelations]);
61
61
  (0, _react.useEffect)(() => {
62
62
  return () => {
63
+ currentGestureRef.current = {
64
+ type: '',
65
+ handlerTag: -1
66
+ };
63
67
  _NativeProxy.NativeProxy.dropGestureHandler(handlerTag);
64
68
  (0, _utils3.scheduleFlushOperations)();
65
69
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_getNextHandlerTag","_useGestureCallbacks","_utils","_utils2","_utils3","_handlersRegistry","_NativeProxy","useGesture","type","config","handlerTag","useMemo","getNextHandlerTag","disableReanimated","Error","tagMessage","prepareConfig","jsEventHandler","reanimatedEventHandler","animatedEventHandler","useGestureCallbacks","shouldUseReanimatedDetector","gestureRelations","prepareRelations","simultaneousWith","requireToFail","block","currentGestureRef","useRef","current","NativeProxy","createGestureHandler","gesture","detectorCallbacks","useEffect","dropGestureHandler","scheduleFlushOperations","preparedConfig","prepareConfigForNativeSide","setGestureHandlerConfig","bindSharedValues","registerGesture","unbindSharedValues","unregisterGesture"],"sourceRoot":"../../../../src","sources":["v3/hooks/useGesture.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAOA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAIA,IAAAO,YAAA,GAAAP,OAAA;AAEO,SAASQ,UAAUA,CACxBC,IAAuB,EACvBC,MAAgD,EACV;EACtC,MAAMC,UAAU,GAAG,IAAAC,cAAO,EAAC,MAAM,IAAAC,oCAAiB,EAAC,CAAC,EAAE,EAAE,CAAC;EACzD,MAAMC,iBAAiB,GAAG,IAAAF,cAAO,EAAC,MAAMF,MAAM,CAACI,iBAAiB,EAAE,EAAE,CAAC;EAErE,IAAIJ,MAAM,CAACI,iBAAiB,KAAKA,iBAAiB,EAAE;IAClD,MAAM,IAAIC,KAAK,CACb,IAAAC,kBAAU,EACR,oFACF,CACF,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UAAU,EACVF,IAAI,EACJC,MAAM,EACNQ,cAAc,EACdC,sBAAsB,EACtBC,oBAAoB,EACpBG,gBAAgB,CAEpB,CAAC;EAED,IAAAY,gBAAS,EAAC,MAAM;IACd,OAAO,MAAM;MACXJ,wBAAW,CAACK,kBAAkB,CAACzB,UAAU,CAAC;MAC1C,IAAA0B,+BAAuB,EAAC,CAAC;IAC3B,CAAC;EACH,CAAC,EAAE,CAAC5B,IAAI,EAAEE,UAAU,CAAC,CAAC;EAEtB,IAAAwB,gBAAS,EAAC,MAAM;IACd,MAAMG,cAAc,GAAG,IAAAC,iCAA0B,EAAC9B,IAAI,EAAEC,MAAM,CAAC;IAC/DqB,wBAAW,CAACS,uBAAuB,CAAC7B,UAAU,EAAE2B,cAAc,CAAC;IAC/D,IAAAD,+BAAuB,EAAC,CAAC;IAEzB,IAAAI,uBAAgB,EAAC/B,MAAM,EAAEC,UAAU,CAAC;IACpC,IAAA+B,iCAAe,EAAC/B,UAAU,EAAEsB,OAAO,CAAC;IAEpC,OAAO,MAAM;MACX,IAAAU,yBAAkB,EAACjC,MAAM,EAAEC,UAAU,CAAC;MACtC,IAAAiC,mCAAiB,EAACjC,UAAU,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,CAACA,UAAU,EAAED,MAAM,EAAED,IAAI,EAAEwB,OAAO,CAAC,CAAC;EAEvC,OAAOA,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_getNextHandlerTag","_useGestureCallbacks","_utils","_utils2","_utils3","_handlersRegistry","_NativeProxy","useGesture","type","config","handlerTag","useMemo","getNextHandlerTag","disableReanimated","Error","tagMessage","prepareConfig","jsEventHandler","reanimatedEventHandler","animatedEventHandler","useGestureCallbacks","shouldUseReanimatedDetector","gestureRelations","prepareRelations","simultaneousWith","requireToFail","block","currentGestureRef","useRef","current","NativeProxy","createGestureHandler","gesture","detectorCallbacks","useEffect","dropGestureHandler","scheduleFlushOperations","preparedConfig","prepareConfigForNativeSide","setGestureHandlerConfig","bindSharedValues","registerGesture","unbindSharedValues","unregisterGesture"],"sourceRoot":"../../../../src","sources":["v3/hooks/useGesture.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAOA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAIA,IAAAO,YAAA,GAAAP,OAAA;AAEO,SAASQ,UAAUA,CACxBC,IAAuB,EACvBC,MAAgD,EACV;EACtC,MAAMC,UAAU,GAAG,IAAAC,cAAO,EAAC,MAAM,IAAAC,oCAAiB,EAAC,CAAC,EAAE,EAAE,CAAC;EACzD,MAAMC,iBAAiB,GAAG,IAAAF,cAAO,EAAC,MAAMF,MAAM,CAACI,iBAAiB,EAAE,EAAE,CAAC;EAErE,IAAIJ,MAAM,CAACI,iBAAiB,KAAKA,iBAAiB,EAAE;IAClD,MAAM,IAAIC,KAAK,CACb,IAAAC,kBAAU,EACR,oFACF,CACF,CAAC;EACH;;EAEA;EACA,IAAAC,oBAAa,EAACP,MAAM,CAAC;;EAErB;EACA,MAAM;IAAEQ,cAAc;IAAEC,sBAAsB;IAAEC;EAAqB,CAAC,GACpE,IAAAC,wCAAmB,EAACV,UAAU,EAAED,MAAM,CAAC;EAEzC,IAAIA,MAAM,CAACY,2BAA2B,IAAI,CAACH,sBAAsB,EAAE;IACjE,MAAM,IAAIJ,KAAK,CAAC,IAAAC,kBAAU,EAAC,6CAA6C,CAAC,CAAC;EAC5E;EAEA,MAAMO,gBAAgB,GAAG,IAAAX,cAAO,EAC9B,MACE,IAAAY,uBAAgB,EACd;IACEC,gBAAgB,EAAEf,MAAM,CAACe,gBAAgB;IACzCC,aAAa,EAAEhB,MAAM,CAACgB,aAAa;IACnCC,KAAK,EAAEjB,MAAM,CAACiB;E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AC/DqB,wBAAW,CAACS,uBAAuB,CAAC7B,UAAU,EAAE2B,cAAc,CAAC;IAC/D,IAAAD,+BAAuB,EAAC,CAAC;IAEzB,IAAAI,uBAAgB,EAAC/B,MAAM,EAAEC,UAAU,CAAC;IACpC,IAAA+B,iCAAe,EAAC/B,UAAU,EAAEsB,OAAO,CAAC;IAEpC,OAAO,MAAM;MACX,IAAAU,yBAAkB,EAACjC,MAAM,EAAEC,UAAU,CAAC;MACtC,IAAAiC,mCAAiB,EAACjC,UAAU,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,CAACA,UAAU,EAAED,MAAM,EAAED,IAAI,EAAEwB,OAAO,CAAC,CAAC;EAEvC,OAAOA,OAAO;AAChB","ignoreList":[]}
@@ -56,6 +56,10 @@ export function useGesture(type, config) {
56
56
  }), [handlerTag, type, config, jsEventHandler, reanimatedEventHandler, animatedEventHandler, gestureRelations]);
57
57
  useEffect(() => {
58
58
  return () => {
59
+ currentGestureRef.current = {
60
+ type: '',
61
+ handlerTag: -1
62
+ };
59
63
  NativeProxy.dropGestureHandler(handlerTag);
60
64
  scheduleFlushOperations();
61
65
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useMemo","useRef","getNextHandlerTag","useGestureCallbacks","prepareConfig","prepareRelations","bindSharedValues","unbindSharedValues","prepareConfigForNativeSide","tagMessage","scheduleFlushOperations","registerGesture","unregisterGesture","NativeProxy","useGesture","type","config","handlerTag","disableReanimated","Error","jsEventHandler","reanimatedEventHandler","animatedEventHandler","shouldUseReanimatedDetector","gestureRelations","simultaneousWith","requireToFail","block","currentGestureRef","current","createGestureHandler","gesture","detectorCallbacks","dropGestureHandler","preparedConfig","setGestureHandlerConfig"],"sourceRoot":"../../../../src","sources":["v3/hooks/useGesture.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,mBAAmB,QAAQ,uBAAu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AAU,EAAED,MAAM,EAAED,IAAI,EAAEgB,OAAO,CAAC,CAAC;EAEvC,OAAOA,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useMemo","useRef","getNextHandlerTag","useGestureCallbacks","prepareConfig","prepareRelations","bindSharedValues","unbindSharedValues","prepareConfigForNativeSide","tagMessage","scheduleFlushOperations","registerGesture","unregisterGesture","NativeProxy","useGesture","type","config","handlerTag","disableReanimated","Error","jsEventHandler","reanimatedEventHandler","animatedEventHandler","shouldUseReanimatedDetector","gestureRelations","simultaneousWith","requireToFail","block","currentGestureRef","current","createGestureHandler","gesture","detectorCallbacks","dropGestureHandler","preparedConfig","setGestureHandlerConfig"],"sourceRoot":"../../../../src","sources":["v3/hooks/useGesture.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SACEC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,EAChBC,kBAAkB,EAClBC,0BAA0B,QACrB,SAAS;AAChB,SAASC,UAAU,QAAQ,aAAa;AAExC,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9D,SACEC,eAAe,EACfC,iBAAiB,QACZ,iCAAiC;AACxC,SAASC,WAAW,QAAQ,gBAAgB;AAE5C,OAAO,SAASC,UAAUA,CACxBC,IAAuB,EACvBC,MAAgD,EACV;EACtC,MAAMC,UAAU,GAAGjB,OAAO,CAAC,MAAME,iBAAiB,CAAC,CAAC,EAAE,EAAE,CAAC;EACzD,MAAMgB,iBAAiB,GAAGlB,OAAO,CAAC,MAAMgB,MAAM,CAACE,iBAAiB,EAAE,EAAE,CAAC;EAErE,IAAIF,MAAM,CAACE,iBAAiB,KAAKA,iBAAiB,EAAE;IAClD,MAAM,IAAIC,KAAK,CACbV,UAAU,CACR,oFACF,CACF,CAAC;EACH;;EAEA;EACAL,aAAa,CAACY,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C;EAEDzB,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX6B,iBAAiB,CAACC,OAAO,GAAG;QAAEd,IAAI,EAAE,EAAE;QAAEE,UAAU,EAAE,CAAC;MAAE,CAAC;MACxDJ,WAAW,CAACoB,kBAAkB,CAAChB,UAAU,CAAC;MAC1CP,uBAAuB,CAAC,CAAC;IAC3B,CAAC;EACH,CAAC,EAAE,CAACK,IAAI,EAAEE,UAAU,CAAC,CAAC;EAEtBlB,SAAS,CAAC,MAAM;IACd,MAAMmC,cAAc,GAAG1B,0BAA0B,CAACO,IAAI,EAAEC,MAAM,CAAC;IAC/DH,WAAW,CAACsB,uBAAuB,CAAClB,UAAU,EAAEiB,cAAc,CAAC;IAC/DxB,uBAAuB,CAAC,CAAC;IAEzBJ,gBAAgB,CAACU,MAAM,EAAEC,UAAU,CAAC;IACpCN,eAAe,CAACM,UAAU,EAAEc,OAAO,CAAC;IAEpC,OAAO,MAAM;MACXxB,kBAAkB,CAACS,MAAM,EAAEC,UAAU,CAAC;MACtCL,iBAAiB,CAACK,UAAU,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,CAACA,UAAU,EAAED,MAAM,EAAED,IAAI,EAAEgB,OAAO,CAAC,CAAC;EAEvC,OAAOA,OAAO;AAChB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useGesture.d.ts","sourceRoot":"","sources":["../../../../src/v3/hooks/useGesture.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAQ/E,wBAAgB,UAAU,CAAC,YAAY,EAAE,OAAO,EAC9C,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,GAC/C,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CA0FtC"}
1
+ {"version":3,"file":"useGesture.d.ts","sourceRoot":"","sources":["../../../../src/v3/hooks/useGesture.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAQ/E,wBAAgB,UAAU,CAAC,YAAY,EAAE,OAAO,EAC9C,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,GAC/C,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CA2FtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-nightly-20260210-746564b1e",
4
4
  "description": "Declarative API exposing native platform touch and gesture system to React Native",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -28,11 +28,24 @@ void RNGestureHandlerDetectorShadowNode::initialize() {
28
28
  children.size() == 1 &&
29
29
  "RNGestureHandlerDetector received more than one child");
30
30
 
31
- const auto clonedChild = children[0]->clone({});
32
- replaceChild(*children[0], clonedChild);
31
+ // Will clone the child and ensure it's not flattened
32
+ replaceChild(*children[0], children[0], 0);
33
33
  }
34
34
  }
35
35
 
36
+ void RNGestureHandlerDetectorShadowNode::appendChild(
37
+ const std::shared_ptr<const ShadowNode> &child) {
38
+ YogaLayoutableShadowNode::appendChild(unflattenNode(child));
39
+ }
40
+
41
+ void RNGestureHandlerDetectorShadowNode::replaceChild(
42
+ const ShadowNode &oldChild,
43
+ const std::shared_ptr<const ShadowNode> &newChild,
44
+ size_t suggestedIndex) {
45
+ YogaLayoutableShadowNode::replaceChild(
46
+ oldChild, unflattenNode(newChild), suggestedIndex);
47
+ }
48
+
36
49
  void RNGestureHandlerDetectorShadowNode::layout(LayoutContext layoutContext) {
37
50
  // TODO: consider allowing more than one child and doing bounding box
38
51
  react_native_assert(getChildren().size() == 1);
@@ -69,4 +82,18 @@ void RNGestureHandlerDetectorShadowNode::layout(LayoutContext layoutContext) {
69
82
  mutableChild->setLayoutMetrics(childmetrics);
70
83
  }
71
84
 
85
+ std::shared_ptr<const ShadowNode>
86
+ RNGestureHandlerDetectorShadowNode::unflattenNode(
87
+ const std::shared_ptr<const ShadowNode> &node) {
88
+ auto clonedNode = node->clone({});
89
+ auto clonedNodeWithProtectedAccess =
90
+ std::static_pointer_cast<RNGestureHandlerDetectorShadowNode>(clonedNode);
91
+
92
+ clonedNodeWithProtectedAccess->traits_.set(ShadowNodeTraits::FormsView);
93
+ clonedNodeWithProtectedAccess->traits_.set(
94
+ ShadowNodeTraits::FormsStackingContext);
95
+
96
+ return clonedNode;
97
+ }
98
+
72
99
  } // namespace facebook::react
@@ -53,9 +53,17 @@ class RNGestureHandlerDetectorShadowNode final
53
53
  initialize();
54
54
  }
55
55
 
56
+ void appendChild(const std::shared_ptr<const ShadowNode> &child) override;
57
+ void replaceChild(
58
+ const ShadowNode &oldChild,
59
+ const std::shared_ptr<const ShadowNode> &newChild,
60
+ size_t suggestedIndex = SIZE_MAX) override;
61
+
56
62
  void layout(LayoutContext layoutContext) override;
57
63
 
58
64
  private:
65
+ std::shared_ptr<const ShadowNode> unflattenNode(
66
+ const std::shared_ptr<const ShadowNode> &node);
59
67
  void initialize();
60
68
 
61
69
  std::optional<LayoutMetrics> previousLayoutMetrics_;
@@ -90,6 +90,7 @@ export function useGesture<THandlerData, TConfig>(
90
90
 
91
91
  useEffect(() => {
92
92
  return () => {
93
+ currentGestureRef.current = { type: '', handlerTag: -1 };
93
94
  NativeProxy.dropGestureHandler(handlerTag);
94
95
  scheduleFlushOperations();
95
96
  };