Skip to content

Commit

Permalink
fix: prevent tappable subviews while scrolling or dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
azimgd committed May 21, 2024
1 parent a6f3e4e commit 35bbe55
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ios/ShadowListContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ @implementation ShadowListContainer {
BOOL _scrollContainerLayoutComplete;
BOOL _scrollContainerLayoutHorizontal;
BOOL _scrollContainerLayoutInverted;
BOOL _scrollContainerScrolling;
}

+ (ComponentDescriptorProvider)componentDescriptorProvider
Expand Down Expand Up @@ -101,6 +102,36 @@ - (void)updateState:(const State::Shared &)state oldState:(const State::Shared &
[self recycle];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
_scrollContainerScrolling = YES;
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (!decelerate) {
[self scrollViewDidEndScrolling:scrollView];
}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self scrollViewDidEndScrolling:scrollView];
}

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
[self scrollViewDidEndScrolling:scrollView];
}

- (void)scrollViewDidEndScrolling:(UIScrollView *)scrollView {
_scrollContainerScrolling = NO;
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (_scrollContainerScrolling) {
return self->_scrollContainer;
}
return [super hitTest:point withEvent:event];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
const auto &props = static_cast<const ShadowListContainerProps &>(*_props);
Expand Down

0 comments on commit 35bbe55

Please sign in to comment.