Skip to content

Commit

Permalink
chore(ios): bring back (currently unused) code related to #712 and #705
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbej committed Dec 14, 2023
1 parent 0dd9b2a commit 0212f97
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ios/RNCPagerScrollView.h
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
31 changes: 31 additions & 0 deletions ios/RNCPagerScrollView.m
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

0 comments on commit 0212f97

Please sign in to comment.