mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-01 22:25:12 +00:00
Fix touch events on Text elements
This commit is contained in:
+21
-18
@@ -59,6 +59,11 @@
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event withTransform:(CGAffineTransform)transform
|
||||
{
|
||||
UIView *hitSelf = [super hitTest:point withEvent:event withTransform:transform];
|
||||
if (hitSelf) {
|
||||
return hitSelf;
|
||||
}
|
||||
|
||||
CGAffineTransform matrix = CGAffineTransformConcat(self.matrix, transform);
|
||||
|
||||
CGPathRef clip = [self getClipPath];
|
||||
@@ -72,25 +77,23 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (RNSVGNode *node in [self.subviews reverseObjectEnumerator]) {
|
||||
if ([node isKindOfClass:[RNSVGNode class]]) {
|
||||
if (event) {
|
||||
node.active = NO;
|
||||
} else if (node.active) {
|
||||
return node;
|
||||
}
|
||||
|
||||
UIView *view = [node hitTest: point withEvent:event withTransform:matrix];
|
||||
|
||||
if (view) {
|
||||
node.active = YES;
|
||||
if (node.responsible || (node != view)) {
|
||||
return view;
|
||||
} else {
|
||||
return self;
|
||||
}
|
||||
}
|
||||
if (![node isKindOfClass:[RNSVGNode class]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event) {
|
||||
node.active = NO;
|
||||
} else if (node.active) {
|
||||
return node;
|
||||
}
|
||||
|
||||
UIView *hitChild = [node hitTest: point withEvent:event withTransform:matrix];
|
||||
|
||||
if (hitChild) {
|
||||
node.active = YES;
|
||||
return (node.responsible || (node != hitChild)) ? hitChild : self;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
|
||||
@@ -266,6 +266,10 @@
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event withTransform:(CGAffineTransform)transform
|
||||
{
|
||||
if (!_hitArea) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (self.active) {
|
||||
if (!event) {
|
||||
self.active = NO;
|
||||
|
||||
@@ -29,8 +29,12 @@
|
||||
[self clip:context];
|
||||
CGContextSaveGState(context);
|
||||
[self setupGlyphContext:context];
|
||||
CGAffineTransform transform = [self getAlignTransform:context];
|
||||
CGPathRef path = [self getPath:context];
|
||||
|
||||
CGAffineTransform transform = [self getAlignTransform:context path:path];
|
||||
CGContextConcatCTM(context, transform);
|
||||
|
||||
[self setHitArea:path];
|
||||
[self renderGroupTo:context];
|
||||
[self releaseCachedPath];
|
||||
CGContextRestoreGState(context);
|
||||
@@ -80,11 +84,6 @@
|
||||
[self popGlyphContext];
|
||||
}
|
||||
|
||||
- (CGAffineTransform)getAlignTransform:(CGContextRef)context
|
||||
{
|
||||
return [self getAlignTransform:context path:[self getGroupPath:context]];
|
||||
}
|
||||
|
||||
- (CGAffineTransform)getAlignTransform:(CGContextRef)context path:(CGPathRef)path
|
||||
{
|
||||
CGFloat width = CGRectGetWidth(CGPathGetBoundingBox(path));
|
||||
|
||||
Reference in New Issue
Block a user