@lodev09/react-native-true-sheet 3.11.5 → 3.11.6

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.
@@ -261,14 +261,12 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
261
261
 
262
262
  dispatch_async(dispatch_get_main_queue(), ^{
263
263
  NSInteger index = [self currentDetentIndex];
264
- [self learnOffsetForDetentIndex:index];
265
-
266
264
  CGFloat detent = [self detentValueForIndex:index];
267
265
  [self.delegate viewControllerDidPresentAtIndex:index position:self.currentPosition detent:detent];
268
266
  [self.delegate viewControllerDidFocus];
269
267
 
270
268
  [self->_grabberView updateAccessibilityValueWithIndex:index detentCount:self->_detents.count];
271
- [self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:@"did present"];
269
+ [self settleAtDetentIndex:index debug:@"did present"];
272
270
  });
273
271
 
274
272
  [self setupGestureRecognizer];
@@ -473,18 +471,17 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
473
471
  if (!_isTransitioning && !_isInteractiveDismiss) {
474
472
  _isTrackingPositionFromLayout = YES;
475
473
 
476
- UIViewController *presented = self.presentedViewController;
477
- BOOL hasPresentedController = presented != nil && !presented.isBeingPresented && !presented.isBeingDismissed;
478
- BOOL realtime = !hasPresentedController;
479
-
480
474
  if (_pendingContentSizeChange || _pendingDetentsChange) {
481
475
  _pendingContentSizeChange = NO;
482
476
  _pendingDetentsChange = NO;
483
- realtime = NO;
484
- [self learnOffsetForDetentIndex:self.currentDetentIndex];
477
+ [self settleAtDetentIndex:self.currentDetentIndex debug:@"layout"];
478
+ } else {
479
+ UIViewController *presented = self.presentedViewController;
480
+ BOOL hasPresentedController = presented != nil && !presented.isBeingPresented && !presented.isBeingDismissed;
481
+ [self emitChangePositionDelegateWithPosition:self.currentPosition
482
+ realtime:!hasPresentedController
483
+ debug:@"layout"];
485
484
  }
486
-
487
- [self emitChangePositionDelegateWithPosition:self.currentPosition realtime:realtime debug:@"layout"];
488
485
  }
489
486
  }
490
487
 
@@ -503,11 +500,10 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
503
500
  _pendingDetentIndex = -1;
504
501
 
505
502
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
506
- [self learnOffsetForDetentIndex:pendingIndex];
507
503
  CGFloat detent = [self detentValueForIndex:pendingIndex];
508
504
  [self.delegate viewControllerDidChangeDetent:pendingIndex position:self.currentPosition detent:detent];
509
505
  [self->_grabberView updateAccessibilityValueWithIndex:pendingIndex detentCount:self->_detents.count];
510
- [self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:@"pending detent change"];
506
+ [self settleAtDetentIndex:pendingIndex debug:@"pending detent change"];
511
507
  });
512
508
  }
513
509
 
@@ -582,9 +578,8 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
582
578
  if (!_isTransitioning) {
583
579
  dispatch_async(dispatch_get_main_queue(), ^{
584
580
  NSInteger index = self.currentDetentIndex;
585
- [self learnOffsetForDetentIndex:index];
586
581
  [self->_grabberView updateAccessibilityValueWithIndex:index detentCount:self->_detents.count];
587
- [self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:@"drag end"];
582
+ [self settleAtDetentIndex:index debug:@"drag end"];
588
583
  });
589
584
  }
590
585
 
@@ -602,6 +597,13 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
602
597
 
603
598
  _isTransitioning = YES;
604
599
 
600
+ // Learn the resolver-vs-actual offset before emitting transition positions so
601
+ // the interpolated index lands exactly on the target detent. The presented
602
+ // frame is already final here (UIKit animates the layer, not the frame).
603
+ if (!self.isBeingDismissed) {
604
+ [self learnOffsetForDetentIndex:self.currentDetentIndex];
605
+ }
606
+
605
607
  CGRect dismissedFrame = CGRectMake(0, self.screenHeight, 0, 0);
606
608
  CGRect presentedFrame = CGRectMake(0, self.currentPosition, 0, 0);
607
609
 
@@ -810,6 +812,16 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
810
812
  [_detentCalculator learnOffsetForDetentIndex:index];
811
813
  }
812
814
 
815
+ /**
816
+ * Learn the resolver-vs-actual offset at a settled detent, then emit the corrected
817
+ * position. Only valid when presentedView's frame is final — never mid-drag or
818
+ * mid-animation, where learning would store a bogus offset.
819
+ */
820
+ - (void)settleAtDetentIndex:(NSInteger)index debug:(NSString *)debug {
821
+ [self learnOffsetForDetentIndex:index];
822
+ [self emitChangePositionDelegateWithPosition:self.currentPosition realtime:NO debug:debug];
823
+ }
824
+
813
825
  - (BOOL)findSegmentForPosition:(CGFloat)position outIndex:(NSInteger *)outIndex outProgress:(CGFloat *)outProgress {
814
826
  return [_detentCalculator findSegmentForPosition:position outIndex:outIndex outProgress:outProgress];
815
827
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.11.5",
3
+ "version": "3.11.6",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",