Skip to content

Commit

Permalink
fix(iOS): fix setPage issue (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
krozniata authored Nov 21, 2022
1 parent 7ff5c15 commit f2d943d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ios/Fabric/RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ - (void)setPageWithoutAnimation:(NSInteger)index {
- (void)goTo:(NSInteger)index animated:(BOOL)animated {
NSInteger numberOfPages = _nativeChildrenViewControllers.count;

_nativePageViewController.view.userInteractionEnabled = NO;

_destinationIndex = index;


Expand Down Expand Up @@ -210,6 +212,7 @@ - (void)setPagerViewControllers:(NSInteger)index
int position = (int) index;
strongEventEmitter.onPageSelected(RNCViewPagerEventEmitter::OnPageSelected{.position = static_cast<double>(position)});
strongSelf->_currentIndex = index;
strongSelf->_nativePageViewController.view.userInteractionEnabled = YES;
}
}];
}
Expand Down
3 changes: 3 additions & 0 deletions ios/ReactNativePageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ - (void)setReactViewControllers:(NSInteger)index

if (finished) {
strongSelf.animating = NO;
strongSelf.reactPageViewController.view.userInteractionEnabled = YES;
}

if (strongSelf.eventDispatcher) {
Expand Down Expand Up @@ -225,6 +226,8 @@ - (void)updateDataSource {
- (void)goTo:(NSInteger)index animated:(BOOL)animated {
NSInteger numberOfPages = self.reactSubviews.count;

_reactPageViewController.view.userInteractionEnabled = NO;

_destinationIndex = index;

if (numberOfPages == 0 || index < 0 || index > numberOfPages - 1) {
Expand Down

0 comments on commit f2d943d

Please sign in to comment.