mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-12 15:29:01 +00:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user