@@ -22,7 +22,9 @@ @interface RNCPagerViewComponentView () <RCTRNCViewPagerViewProtocol, UIPageView
2222
2323@implementation RNCPagerViewComponentView {
2424 LayoutMetrics _layoutMetrics;
25+ LayoutMetrics _oldLayoutMetrics;
2526 UIScrollView *scrollView;
27+ BOOL transitioning;
2628}
2729
2830// Needed because of this: https://github.com/facebook/react-native/pull/37274
@@ -111,9 +113,14 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
111113
112114
113115-(void )updateLayoutMetrics : (const facebook::react::LayoutMetrics &)layoutMetrics oldLayoutMetrics : (const facebook::react::LayoutMetrics &)oldLayoutMetrics {
114- [super updateLayoutMetrics: layoutMetrics oldLayoutMetrics: _layoutMetrics];
115- self.contentView .frame = RCTCGRectFromRect (layoutMetrics.getContentFrame ());
116+ _oldLayoutMetrics = oldLayoutMetrics;
116117 _layoutMetrics = layoutMetrics;
118+
119+ if (transitioning) {
120+ return ;
121+ }
122+
123+ [super updateLayoutMetrics: layoutMetrics oldLayoutMetrics: _layoutMetrics];
117124}
118125
119126
@@ -223,12 +230,15 @@ - (void)setPagerViewControllers:(NSInteger)index
223230 [self enableSwipe ];
224231 return ;
225232 }
226-
233+
234+ transitioning = YES ;
235+
227236 __weak RNCPagerViewComponentView *weakSelf = self;
228237 [_nativePageViewController setViewControllers: @[[_nativeChildrenViewControllers objectAtIndex: index]]
229238 direction: direction
230239 animated: animated
231240 completion: ^(BOOL finished) {
241+ self->transitioning = NO ;
232242 __strong RNCPagerViewComponentView *strongSelf = weakSelf;
233243 [strongSelf enableSwipe ];
234244 if (strongSelf->_eventEmitter != nullptr ) {
@@ -237,6 +247,7 @@ - (void)setPagerViewControllers:(NSInteger)index
237247 strongEventEmitter.onPageSelected (RNCViewPagerEventEmitter::OnPageSelected{.position = static_cast <double >(position)});
238248 strongSelf->_currentIndex = index;
239249 }
250+ [strongSelf updateLayoutMetrics: strongSelf->_layoutMetrics oldLayoutMetrics: strongSelf->_oldLayoutMetrics];
240251 }];
241252}
242253
0 commit comments