[ios] fix hit testing of nested svg and invalidation on changes.

This commit is contained in:
Mikael Sand
2019-02-04 02:37:14 +02:00
parent 14791652ee
commit 8cf4b8e695
2 changed files with 31 additions and 15 deletions
+20 -14
View File
@@ -173,20 +173,26 @@
}
}
for (RNSVGNode *node in [self.subviews reverseObjectEnumerator]) {
if (![node isKindOfClass:[RNSVGNode class]] || [node isKindOfClass:[RNSVGMask class]]) {
continue;
}
if (event) {
node.active = NO;
}
UIView *hitChild = [node hitTest:transformed withEvent:event];
if (hitChild) {
node.active = YES;
return (node.responsible || (node != hitChild)) ? hitChild : self;
for (UIView *node in [self.subviews reverseObjectEnumerator]) {
if ([node isKindOfClass:[RNSVGNode class]]) {
if ([node isKindOfClass:[RNSVGMask class]]) {
continue;
}
RNSVGNode* svgNode = (RNSVGNode*)node;
if (event) {
svgNode.active = NO;
}
UIView *hitChild = [svgNode hitTest:transformed withEvent:event];
if (hitChild) {
svgNode.active = YES;
return (svgNode.responsible || (svgNode != hitChild)) ? hitChild : self;
}
} else if ([node isKindOfClass:[RNSVGSvgView class]]) {
RNSVGSvgView* svgView = (RNSVGSvgView*)node;
UIView *hitChild = [svgView hitTest:transformed withEvent:event];
if (hitChild) {
return hitChild;
}
}
}
+11 -1
View File
@@ -66,6 +66,16 @@
- (void)invalidate
{
UIView* parent = self.superview;
if ([parent isKindOfClass:[RNSVGNode class]]) {
if (!rendered) {
return;
}
RNSVGNode* svgNode = (RNSVGNode*)parent;
[svgNode invalidate];
rendered = false;
return;
}
[self setNeedsDisplay];
}
@@ -158,7 +168,7 @@
}
- (void)drawToContext:(CGContextRef)context withRect:(CGRect)rect {
rendered = true;
self.initialCTM = CGContextGetCTM(context);
self.invInitialCTM = CGAffineTransformInvert(self.initialCTM);
if (self.align) {