File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
1010- (instancetype )initWithEventDispatcher : (RCTEventDispatcher *)eventDispatcher ;
1111
1212@property (nonatomic ) NSInteger initialPage;
13+ @property (nonatomic ) NSInteger previousIndex;
1314@property (nonatomic ) NSInteger currentIndex;
1415@property (nonatomic ) NSInteger pageMargin;
1516@property (nonatomic , readonly ) BOOL scrollEnabled;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
3636 if (self = [super init ]) {
3737 _scrollEnabled = YES ;
3838 _pageMargin = 0 ;
39+ _previousIndex = -1 ;
3940 _transitionStyle = UIPageViewControllerTransitionStyleScroll;
4041 _orientation = UIPageViewControllerNavigationOrientationHorizontal;
4142 _currentIndex = 0 ;
@@ -173,7 +174,10 @@ - (void)setReactViewControllers:(NSInteger)index
173174 weakSelf.currentView = controller.view ;
174175
175176 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;
177181 }
178182
179183 }];
@@ -280,7 +284,7 @@ - (void)pageViewController:(UIPageViewController *)pageViewController
280284 NSUInteger currentIndex = [self .reactSubviews indexOfObject: currentVC.view];
281285
282286 self.currentIndex = currentIndex;
283-
287+ self. previousIndex = currentIndex - 1 ;
284288 self.currentView = currentVC.view ;
285289 self.reactPageIndicatorView .currentPage = currentIndex;
286290
You can’t perform that action at this time.
0 commit comments