-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
NOTE: This file is *not* currently used, for context see: | ||
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410295171 | ||
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410316201 | ||
*/ | ||
|
||
@interface RNCPagerScrollView : UIScrollView <UIGestureRecognizerDelegate> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
NOTE: This file is *not* currently used, for context see: | ||
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410295171 | ||
- https://github.com/callstack/react-native-pager-view/pull/783#discussion_r1410316201 | ||
*/ | ||
|
||
#import "RNCPagerScrollView.h" | ||
|
||
@implementation RNCPagerScrollView | ||
- (instancetype)initWithFrame:(CGRect)frame { | ||
if (self = [super initWithFrame:frame]) { | ||
self.panGestureRecognizer.delegate = self; | ||
} | ||
return self; | ||
} | ||
|
||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { | ||
if (gestureRecognizer == self.panGestureRecognizer) { | ||
CGPoint velocity = [self.panGestureRecognizer velocityInView:self]; | ||
UIUserInterfaceLayoutDirection layoutDirection = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute]; | ||
BOOL isLTR = UIUserInterfaceLayoutDirectionLeftToRight == layoutDirection; | ||
BOOL isBackGesture = (isLTR && velocity.x > 0) || (!isLTR && velocity.x < 0); | ||
// if it's back gesture and scroll view is at the beginning of scroll we allow simultaneous gesture | ||
if (isBackGesture && self.contentOffset.x <= 0) { | ||
return YES; | ||
} | ||
} | ||
return NO; | ||
} | ||
|
||
@end |