Skip to content

Commit 84c62d9

Browse files
fix(ios): Changing swipe direction flickers (#330) (#356)
1 parent 1d4dffe commit 84c62d9

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

example/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ PODS:
185185
- React-cxxreact (= 0.63.4)
186186
- React-jsi (= 0.63.4)
187187
- React-jsinspector (0.63.4)
188-
- react-native-pager-view (5.1.7):
188+
- react-native-pager-view (5.1.8):
189189
- React-Core
190190
- react-native-safe-area-context (3.2.0):
191191
- React-Core
@@ -382,7 +382,7 @@ SPEC CHECKSUMS:
382382
React-jsi: a0418934cf48f25b485631deb27c64dc40fb4c31
383383
React-jsiexecutor: 93bd528844ad21dc07aab1c67cb10abae6df6949
384384
React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a
385-
react-native-pager-view: c60a26be051a4b88427f2475e173b5c112e98d17
385+
react-native-pager-view: a0b86051cb34c1868601ba65a8133e3b7a2830b5
386386
react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79
387387
React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336
388388
React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b
@@ -402,4 +402,4 @@ SPEC CHECKSUMS:
402402

403403
PODFILE CHECKSUM: ff595481d97548cf6367f753d945ef2a7fc1f818
404404

405-
COCOAPODS: 1.10.0
405+
COCOAPODS: 1.10.1

ios/ReactNativePageView.m

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,13 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
382382
}
383383

384384
float absoluteOffset = fabs(offset);
385-
if(absoluteOffset > 1) {
386-
absoluteOffset = 1.0;
387-
}
388385

389-
NSString *scrollDirection = [self determineScrollDirection:scrollView];
390-
NSString *oppositeDirection = self.isHorizontal ? @"left" : @"up";
391386
NSInteger position = self.currentIndex;
392-
393-
if(absoluteOffset > 0) {
394-
position = [scrollDirection isEqual: oppositeDirection] ? self.currentIndex - 1 : self.currentIndex;
395-
absoluteOffset = [scrollDirection isEqual: oppositeDirection] ? 1 - absoluteOffset : absoluteOffset;
387+
388+
if(offset<0 && position>0){
389+
position = self.currentIndex - 1;
390+
absoluteOffset = 1 - absoluteOffset;
396391
}
397-
398392

399393
self.lastContentOffset = scrollView.contentOffset;
400394
[self.eventDispatcher sendEvent:[[RCTOnPageScrollEvent alloc] initWithReactTag:self.reactTag position:@(position) offset:@(absoluteOffset)]];

0 commit comments

Comments
 (0)