Skip to content

Commit

Permalink
Forward hitTest:withEvent and piontInside:withEvent: to node within _…
Browse files Browse the repository at this point in the history
…ASCollectionViewCell (#1268)
  • Loading branch information
maicki committed Dec 6, 2018
1 parent 758afab commit 86a853e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Source/Details/_ASCollectionViewCell.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//

#import <AsyncDisplayKit/_ASCollectionViewCell.h>
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>

#import <AsyncDisplayKit/ASCellNode+Internal.h>
#import <AsyncDisplayKit/ASCollectionElement.h>
Expand Down Expand Up @@ -94,6 +95,29 @@ - (void)layoutSubviews
self.node.frame = self.contentView.bounds;
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
/**
* The documentation for hitTest:withEvent: on an UIView explicitly states the fact that:
* it ignores view objects that are hidden, that have disabled user interactions, or have an
* alpha level less than 0.01.
* To be able to determine if the collection view cell should skip going further down the tree
* based on the states above we use a valid point within the cells bounds and check the
* superclass hitTest:withEvent: implementation. If this returns a valid value we can go on with
* checking the node as it's expected to not be in one of these states.
*/
if (![super hitTest:self.bounds.origin withEvent:event]) {
return nil;
}

return [self.node hitTest:point withEvent:event];
}

- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event
{
return [self.node pointInside:point withEvent:event];
}

@end

/**
Expand Down

0 comments on commit 86a853e

Please sign in to comment.