@@ -22,7 +22,9 @@ @interface RNCPagerViewComponentView () <RCTRNCViewPagerViewProtocol, UIPageView
22
22
23
23
@implementation RNCPagerViewComponentView {
24
24
LayoutMetrics _layoutMetrics;
25
+ LayoutMetrics _oldLayoutMetrics;
25
26
UIScrollView *scrollView;
27
+ BOOL transitioning;
26
28
}
27
29
28
30
// Needed because of this: https://github.com/facebook/react-native/pull/37274
@@ -111,9 +113,14 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
111
113
112
114
113
115
-(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;
116
117
_layoutMetrics = layoutMetrics;
118
+
119
+ if (transitioning) {
120
+ return ;
121
+ }
122
+
123
+ [super updateLayoutMetrics: layoutMetrics oldLayoutMetrics: _layoutMetrics];
117
124
}
118
125
119
126
@@ -223,12 +230,15 @@ - (void)setPagerViewControllers:(NSInteger)index
223
230
[self enableSwipe ];
224
231
return ;
225
232
}
226
-
233
+
234
+ transitioning = YES ;
235
+
227
236
__weak RNCPagerViewComponentView *weakSelf = self;
228
237
[_nativePageViewController setViewControllers: @[[_nativeChildrenViewControllers objectAtIndex: index]]
229
238
direction: direction
230
239
animated: animated
231
240
completion: ^(BOOL finished) {
241
+ self->transitioning = NO ;
232
242
__strong RNCPagerViewComponentView *strongSelf = weakSelf;
233
243
[strongSelf enableSwipe ];
234
244
if (strongSelf->_eventEmitter != nullptr ) {
@@ -237,6 +247,7 @@ - (void)setPagerViewControllers:(NSInteger)index
237
247
strongEventEmitter.onPageSelected (RNCViewPagerEventEmitter::OnPageSelected{.position = static_cast <double >(position)});
238
248
strongSelf->_currentIndex = index;
239
249
}
250
+ [strongSelf updateLayoutMetrics: strongSelf->_layoutMetrics oldLayoutMetrics: strongSelf->_oldLayoutMetrics];
240
251
}];
241
252
}
242
253
0 commit comments