Skip to content

Commit 0212f97

Browse files
committed
chore(ios): bring back (currently unused) code related to #712 and #705
1 parent 0dd9b2a commit 0212f97

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

ios/RNCPagerScrollView.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
NOTE: This file is *not* currently used, for context see:
3+
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410295171
4+
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410316201
5+
*/
6+
7+
@interface RNCPagerScrollView : UIScrollView <UIGestureRecognizerDelegate>
8+
@end

ios/RNCPagerScrollView.m

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
NOTE: This file is *not* currently used, for context see:
3+
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410295171
4+
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410316201
5+
*/
6+
7+
#import "RNCPagerScrollView.h"
8+
9+
@implementation RNCPagerScrollView
10+
- (instancetype)initWithFrame:(CGRect)frame {
11+
if (self = [super initWithFrame:frame]) {
12+
self.panGestureRecognizer.delegate = self;
13+
}
14+
return self;
15+
}
16+
17+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
18+
if (gestureRecognizer == self.panGestureRecognizer) {
19+
CGPoint velocity = [self.panGestureRecognizer velocityInView:self];
20+
UIUserInterfaceLayoutDirection layoutDirection = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute];
21+
BOOL isLTR = UIUserInterfaceLayoutDirectionLeftToRight == layoutDirection;
22+
BOOL isBackGesture = (isLTR && velocity.x > 0) || (!isLTR && velocity.x < 0);
23+
// if it's back gesture and scroll view is at the beginning of scroll we allow simultaneous gesture
24+
if (isBackGesture && self.contentOffset.x <= 0) {
25+
return YES;
26+
}
27+
}
28+
return NO;
29+
}
30+
31+
@end

0 commit comments

Comments
 (0)