Skip to content

Commit

Permalink
chore(ios): add log for nest scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Feb 26, 2025
1 parent 1e9e530 commit ad13ad4
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@


static NSString *const kHippyNestedScrollLog= @"NestedScroll";
#define HippyNSLogTrace(...) HippyLogTrace(@"%@ %p %@", kHippyNestedScrollLog, self, [NSString stringWithFormat:__VA_ARGS__])
#define HippyNSLogTrace(...) HippyLogTrace(@"%@ %p(%@) %@", \
kHippyNestedScrollLog, self, isOuter ? @"Outer" : @"Inner", [NSString stringWithFormat:__VA_ARGS__])
#define HippyNSLogTrace2(isOuter, ...) HippyLogTrace(@"%@ %p(%@) %@", \
kHippyNestedScrollLog, self, isOuter ? @"Outer" : @"Inner", [NSString stringWithFormat:__VA_ARGS__])
#define HIPPY_NESTED_OPEN_BOUNCES 0 // Turn off the outer bounces feature for now


Expand Down Expand Up @@ -186,14 +189,12 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// 1.1 If the two ScrollViews do not intersect at all, ignore.
if (isOuter && !outerScrollView.activeInnerScrollView && !isIntersect(outerScrollView, innerScrollView)) {
HippyNSLogTrace(@"No Intersect return. %p", sv);
HippyNSLogTrace(@"outer bounds: %@, innerFrame in outer: %@", NSStringFromCGRect(outerScrollView.bounds),
NSStringFromCGRect([sv convertRect:innerScrollView.frame fromView:(UIView *)innerScrollView]));
return;
}

HippyNSLogTrace(@"%@(%p) did scroll: %@",
isOuter ? @"Outer" : @"Inner", sv,
isOuter ?
NSStringFromCGPoint(outerScrollView.contentOffset) :
NSStringFromCGPoint(innerScrollView.contentOffset));
HippyNSLogTrace(@"start handle (%p) did scroll: %@", sv, NSStringFromCGPoint(sv.contentOffset));

// 2. Lock inner scrollview if necessary
if ([self isDirection:direction hasPriority:HippyNestedScrollPriorityParent]) {
Expand Down Expand Up @@ -319,18 +320,17 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {

// 4. Update the lastContentOffset record
sv.lastContentOffset = sv.contentOffset;
HippyNSLogTrace(@"end handle %@(%p) scroll -------------",
isOuter ? @"Outer" : @"Inner", sv);
HippyNSLogTrace(@"end handle (%p) scroll -------------", sv);
}


- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if (scrollView == self.outerScrollView) {
self.shouldUnlockOuterScrollView = NO;
HippyNSLogTrace(@"reset outer scroll lock");
HippyNSLogTrace2(YES, @"reset outer scroll lock");
} else if (scrollView == self.innerScrollView) {
self.shouldUnlockInnerScrollView = NO;
HippyNSLogTrace(@"reset inner scroll lock");
HippyNSLogTrace2(NO, @"reset inner scroll lock");
}

dispatch_async(dispatch_get_main_queue(), ^{
Expand Down

0 comments on commit ad13ad4

Please sign in to comment.