Skip to content

Commit

Permalink
feat(ios): nested scroll api support part3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Dec 11, 2024
1 parent 9c3d9ea commit 34be41d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,19 @@ - (BOOL)shouldRecognizeScrollGestureSimultaneouslyWithView:(UIView *)view {

+ (id<HippyScrollableProtocol>)findNestedOuterScrollView:(UIScrollView *)innerScrollView {
// Use superview.superview since scrollview is a subview of hippy view.
UIView *outerScrollView = innerScrollView.superview.superview;
UIView<HippyScrollableProtocol> *innerScrollable = (UIView<HippyScrollableProtocol> *)innerScrollView.superview;
UIView *outerScrollView = innerScrollable.superview;
while (outerScrollView) {
if ([outerScrollView conformsToProtocol:@protocol(HippyScrollableProtocol)]) {
break;
} else {
outerScrollView = outerScrollView.superview;
UIView<HippyScrollableProtocol> *outerScrollable = (UIView<HippyScrollableProtocol> *)outerScrollView;
// Make sure to find scrollable with same direction.
BOOL isInnerHorizontal = [innerScrollable respondsToSelector:@selector(horizontal)] ? [innerScrollable horizontal] : NO;
BOOL isOuterHorizontal = [outerScrollable respondsToSelector:@selector(horizontal)] ? [outerScrollable horizontal] : NO;
if (isInnerHorizontal == isOuterHorizontal) {
break;
}
}
outerScrollView = outerScrollView.superview;
}
return (id<HippyScrollableProtocol>)outerScrollView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@

@optional

/// Return whether is horizontal, optional, default NO.
- (BOOL)horizontal;

/**
* Set components scroll to location offset
*
Expand Down

0 comments on commit 34be41d

Please sign in to comment.