@@ -149,3 +149,56 @@ index 1e1246f709feb04c01cf3221472cc1219a8fffac..f526d4fe2d2738becbe8d29c59d1105a
149149 }>;
150150
151151 export interface SwipeableMethods {
152+ diff --git a/apple/Handlers/RNPanHandler.m b/apple/Handlers/RNPanHandler.m
153+ --- a/apple/Handlers/RNPanHandler.m
154+ +++ b/apple/Handlers/RNPanHandler.m
155+ @@ -31,6 +31,7 @@
156+ @property (nonatomic) CGFloat failOffsetYStart;
157+ @property (nonatomic) CGFloat failOffsetYEnd;
158+ @property (nonatomic) CGFloat activateAfterLongPress;
159+ + @property (nonatomic) BOOL handlingTouchStart;
160+
161+ #if !TARGET_OS_OSX && !TARGET_OS_TV
162+ @property (atomic, readonly, strong) RNGHStylusData *stylusData;
163+ @@ -126,9 +127,14 @@
164+
165+ - (void)interactionsBegan:(NSSet *)touches withEvent:(UIEvent *)event
166+ {
167+ - if (self.state == UIGestureRecognizerStatePossible && ![self.delegate gestureRecognizerShouldBegin:self]) {
168+ - self.state = UIGestureRecognizerStateFailed;
169+ - return;
170+ + if (self.state == UIGestureRecognizerStatePossible) {
171+ + self.handlingTouchStart = touches.count > 0;
172+ + BOOL shouldBegin = [self.delegate gestureRecognizerShouldBegin:self];
173+ + self.handlingTouchStart = NO;
174+ + if (!shouldBegin) {
175+ + self.state = UIGestureRecognizerStateFailed;
176+ + return;
177+ + }
178+ }
179+
180+ if (touches.count == 0) {
181+ @@ -476,6 +482,23 @@
182+
183+ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
184+ {
185+ + #if !TARGET_OS_OSX && !TARGET_OS_TV
186+ + RNBetterPanGestureRecognizer *recognizer = (RNBetterPanGestureRecognizer *)gestureRecognizer;
187+ + if (!recognizer.handlingTouchStart && recognizer.allowedScrollTypesMask != 0 && recognizer.numberOfTouches == 0) {
188+ + // Trackpad scroll events can begin without touchesMoved enforcing failure
189+ + // offsets. Reject vertical scrolling before a horizontal row pan cancels
190+ + // the enclosing UIScrollView. The manual touch-start preflight above has
191+ + // no current translation yet, so leave that path to the touch callbacks.
192+ + CGPoint translation = [recognizer translationInView:recognizer.view.window];
193+ + BOOL horizontalOnly = (!isnan(recognizer.activeOffsetXStart) || !isnan(recognizer.activeOffsetXEnd)) &&
194+ + isnan(recognizer.activeOffsetYStart) && isnan(recognizer.activeOffsetYEnd);
195+ + if ([recognizer shouldFailUnderCustomCriteria] ||
196+ + (horizontalOnly && fabs(translation.y) > fabs(translation.x))) {
197+ + return NO;
198+ + }
199+ + }
200+ + #endif
201+ +
202+ RNGestureHandlerState savedState = _lastState;
203+ BOOL shouldBegin = [super gestureRecognizerShouldBegin:gestureRecognizer];
204+ _lastState = savedState;
0 commit comments