[ios] Fix touch handling in groups

Check all children before current node itself.
Add shortcut check to return active node if `event` is null. Otherwise
it may return wrong node which have higher z-index value.
This commit is contained in:
Maksym Komarychev
2018-04-05 16:05:37 +03:00
parent 046c7efc04
commit de01bb8638

View File

@@ -61,6 +61,7 @@
return YES;
}];
[self setHitArea:[self getPath:context]];
[self popGlyphContext];
}
@@ -113,16 +114,19 @@
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGPoint transformed = CGPointApplyAffineTransform(point, self.invmatrix);
UIView *hitSelf = [super hitTest:transformed withEvent:event];
if (hitSelf) {
return hitSelf;
}
CGPathRef clip = [self getClipPath];
if (clip && !CGPathContainsPoint(clip, nil, transformed, self.clipRule == kRNSVGCGFCRuleEvenodd)) {
return nil;
}
if (!event) {
NSPredicate *const anyActive = [NSPredicate predicateWithFormat:@"active == TRUE"];
NSArray *const filtered = [self.subviews filteredArrayUsingPredicate:anyActive];
if ([filtered count] != 0) {
return filtered.firstObject;
}
}
for (RNSVGNode *node in [self.subviews reverseObjectEnumerator]) {
if (![node isKindOfClass:[RNSVGNode class]]) {
@@ -142,7 +146,12 @@
return (node.responsible || (node != hitChild)) ? hitChild : self;
}
}
UIView *hitSelf = [super hitTest:transformed withEvent:event];
if (hitSelf) {
return hitSelf;
}
return nil;
}