Skip to content

Commit 7b30662

Browse files
authored
Merge pull request alibaba#1968 from ZhaoXigua/ios-bugfix-stickyAndSliderNeighbor
Ios bugfix sticky and slider neighbor
2 parents 9dc5f8c + b982bf3 commit 7b30662

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m

+20-1
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,23 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gesture shouldReceiveTouch:(UIT
514514
return YES;
515515
}
516516

517+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
518+
//if the view which the otherGestureRecognizer works on is a scrollview and also it is scrollEnabled vertically ,at this time,we should not block the guesture from being recognized by the otherGestureRecognize
519+
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
520+
if ([otherGestureRecognizer.view isKindOfClass:[UIScrollView class]]) {
521+
UIScrollView* scrollview = (UIScrollView *)otherGestureRecognizer.view;
522+
if (scrollview.scrollEnabled) {
523+
UIPanGestureRecognizer* panRcgn= (UIPanGestureRecognizer *)gestureRecognizer;
524+
//check offset for confirming vertival movement
525+
if (fabs([panRcgn translationInView:panRcgn.view].y) > fabs([panRcgn translationInView:panRcgn.view].x)*16) {
526+
return YES;
527+
}
528+
}
529+
}
530+
}
531+
return NO;
532+
}
533+
517534

518535
- (void)didPan:(UIPanGestureRecognizer *)panGesture
519536
{
@@ -526,11 +543,12 @@ - (void)didPan:(UIPanGestureRecognizer *)panGesture
526543
_scrolling = NO;
527544
_decelerating = NO;
528545
_previousTranslation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x;
529-
546+
530547
[_delegate sliderNeighborWillBeginDragging:self];
531548
break;
532549
}
533550
case UIGestureRecognizerStateEnded:
551+
534552
case UIGestureRecognizerStateCancelled:
535553
case UIGestureRecognizerStateFailed:
536554
{
@@ -566,6 +584,7 @@ - (void)didPan:(UIPanGestureRecognizer *)panGesture
566584
}
567585
case UIGestureRecognizerStateChanged:
568586
{
587+
569588
CGFloat translation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x;
570589
CGFloat velocity = _vertical? [panGesture velocityInView:self].y: [panGesture velocityInView:self].x;
571590

0 commit comments

Comments
 (0)