Skip to content

Commit 363c745

Browse files
fix(ios): offset is changing while overDrag is disabled (#363)
1 parent ad9df5c commit 363c745

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

ios/ReactNativePageView.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,6 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
363363

364364
float offset = 0;
365365

366-
if (!_overdrag) {
367-
if (_currentIndex == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width) {
368-
scrollView.contentOffset = CGPointMake(scrollView.bounds.size.width, 0);
369-
} else if (_currentIndex == _reactPageIndicatorView.numberOfPages - 1 && scrollView.contentOffset.x > scrollView.bounds.size.width) {
370-
scrollView.contentOffset = CGPointMake(scrollView.bounds.size.width, 0);
371-
}
372-
}
373-
374366
if (self.isHorizontal) {
375367
if (self.frame.size.width != 0) {
376368
offset = (point.x - self.frame.size.width)/self.frame.size.width;
@@ -390,6 +382,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
390382
absoluteOffset = 1 - absoluteOffset;
391383
}
392384

385+
if (!_overdrag) {
386+
if (_currentIndex == 0 && scrollView.contentOffset.x < scrollView.bounds.size.width) {
387+
scrollView.contentOffset = CGPointMake(scrollView.bounds.size.width, 0);
388+
absoluteOffset=0;
389+
} else if (_currentIndex == _reactPageIndicatorView.numberOfPages - 1 && scrollView.contentOffset.x > scrollView.bounds.size.width) {
390+
scrollView.contentOffset = CGPointMake(scrollView.bounds.size.width, 0);
391+
absoluteOffset=0;
392+
}
393+
}
394+
393395
self.lastContentOffset = scrollView.contentOffset;
394396
[self.eventDispatcher sendEvent:[[RCTOnPageScrollEvent alloc] initWithReactTag:self.reactTag position:@(position) offset:@(absoluteOffset)]];
395397
}

0 commit comments

Comments
 (0)