react-native-swipeable-actions 0.1.11 → 0.1.12

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.
@@ -291,9 +291,6 @@ public class SwipeableView: ExpoView {
291
291
  // Auto-close work item for tracking and cancellation
292
292
  private var autoCloseWorkItem: DispatchWorkItem?
293
293
 
294
- // Override onSwipeEnd state when autoClose triggers close() (emit "open" instead of "closed")
295
- private var autoCloseEndEventOverride = false
296
-
297
294
  // UIViewPropertyAnimator for interruptible animations (2.1, 2.2)
298
295
  private var currentAnimator: UIViewPropertyAnimator?
299
296
 
@@ -481,8 +478,7 @@ public class SwipeableView: ExpoView {
481
478
  DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: retryWorkItem)
482
479
  } else if isOpen {
483
480
  // Emit "open" state when autoClose completes - user's swipe intent was achieved
484
- autoCloseEndEventOverride = true
485
- close()
481
+ close(autoCloseOverride: true)
486
482
  }
487
483
  }
488
484
 
@@ -546,12 +542,27 @@ public class SwipeableView: ExpoView {
546
542
  // views that UIView.subviews would otherwise include.
547
543
  public override func mountChildComponentView(_ childComponentView: UIView, index: Int) {
548
544
  super.mountChildComponentView(childComponentView, index: index)
545
+ // Incoming child may carry a stale transform/zPosition from Fabric recycling;
546
+ // reset it (refreshChildAssignments re-applies the open transform when open).
547
+ childComponentView.transform = .identity
548
+ childComponentView.layer.zPosition = 0
549
549
  let clampedIndex = min(max(index, 0), reactChildren.count)
550
550
  reactChildren.insert(childComponentView, at: clampedIndex)
551
551
  refreshChildAssignments()
552
552
  }
553
553
 
554
554
  public override func unmountChildComponentView(_ childComponentView: UIView, index: Int) {
555
+ // Content recycled mid-animation: stop the animator before contentView is
556
+ // nil'd below, else it keeps writing a transform onto the pooled view.
557
+ // (Android skips this — RN zeroes translationX on recycle; port if needed.)
558
+ if childComponentView === contentView {
559
+ currentAnimator?.stopAnimation(true)
560
+ currentAnimator = nil
561
+ isAnimating = false
562
+ stopProgressUpdates()
563
+ cancelAutoClose() // a pending timer would fire on the reused view
564
+ }
565
+
555
566
  // Fabric recycles UIView instances. Before handing this child back, undo any
556
567
  // transform / zPosition we may have applied — otherwise the next React
557
568
  // component that receives this recycled UIView inherits our stale state and
@@ -907,7 +918,9 @@ public class SwipeableView: ExpoView {
907
918
  onSwipeProgress(["progress": 1.0, "translationX": targetX])
908
919
  }
909
920
 
910
- func close(animated: Bool = true, velocity: CGFloat = 0) {
921
+ // autoCloseOverride is a value, not a sticky flag: an interrupted close (which
922
+ // never runs the completion) can't strand it and mislabel a later close as "open".
923
+ func close(animated: Bool = true, velocity: CGFloat = 0, autoCloseOverride: Bool = false) {
911
924
  cancelAutoClose()
912
925
  stopProgressUpdates()
913
926
 
@@ -951,8 +964,7 @@ public class SwipeableView: ExpoView {
951
964
  self.actionsView?.transform = CGAffineTransform(translationX: actionsOffset, y: 0)
952
965
  self.onSwipeProgress(["progress": 0.0, "translationX": 0.0])
953
966
  // Emit "open" when autoClose completes - user's swipe intent was achieved
954
- let endState = self.autoCloseEndEventOverride ? "open" : "closed"
955
- self.autoCloseEndEventOverride = false
967
+ let endState = autoCloseOverride ? "open" : "closed"
956
968
  self.onSwipeEnd(["state": endState])
957
969
 
958
970
  // Restore first responder if it was lost during swipe (keyboard preservation)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-swipeable-actions",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "High-performance native swipeable row component for React Native using Expo Modules",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",