File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
10
10
- (instancetype )initWithEventDispatcher : (RCTEventDispatcher *)eventDispatcher ;
11
11
12
12
@property (nonatomic ) NSInteger initialPage;
13
+ @property (nonatomic ) NSInteger previousIndex;
13
14
@property (nonatomic ) NSInteger currentIndex;
14
15
@property (nonatomic ) NSInteger pageMargin;
15
16
@property (nonatomic , readonly ) BOOL scrollEnabled;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
36
36
if (self = [super init ]) {
37
37
_scrollEnabled = YES ;
38
38
_pageMargin = 0 ;
39
+ _previousIndex = -1 ;
39
40
_transitionStyle = UIPageViewControllerTransitionStyleScroll;
40
41
_orientation = UIPageViewControllerNavigationOrientationHorizontal;
41
42
_currentIndex = 0 ;
@@ -173,7 +174,10 @@ - (void)setReactViewControllers:(NSInteger)index
173
174
weakSelf.currentView = controller.view ;
174
175
175
176
if (weakSelf.eventDispatcher ) {
176
- [weakSelf.eventDispatcher sendEvent: [[RCTOnPageSelected alloc ] initWithReactTag: weakSelf.reactTag position: @(index) coalescingKey: coalescingKey]];
177
+ if (_previousIndex != _currentIndex){
178
+ [weakSelf.eventDispatcher sendEvent: [[RCTOnPageSelected alloc ] initWithReactTag: weakSelf.reactTag position: @(index) coalescingKey: coalescingKey]];
179
+ }
180
+ _previousIndex = _currentIndex;
177
181
}
178
182
179
183
}];
@@ -280,7 +284,7 @@ - (void)pageViewController:(UIPageViewController *)pageViewController
280
284
NSUInteger currentIndex = [self .reactSubviews indexOfObject: currentVC.view];
281
285
282
286
self.currentIndex = currentIndex;
283
-
287
+ self. previousIndex = currentIndex - 1 ;
284
288
self.currentView = currentVC.view ;
285
289
self.reactPageIndicatorView .currentPage = currentIndex;
286
290
You can’t perform that action at this time.
0 commit comments