From 6ebd928ab4e33202c3e83cf7ed8627d9b76ed5b6 Mon Sep 17 00:00:00 2001 From: Horcrux Date: Sat, 6 Aug 2016 23:17:38 +0800 Subject: [PATCH] fix Text cannot handle touch events bug --- Example/examples/TouchEvents.js | 6 +++--- elements/Text.js | 12 +++++------- ios/Elements/RNSVGGroup.m | 1 - ios/Elements/RNSVGPath.m | 2 -- ios/RNSVGRenderable.m | 2 +- lib/extract/extractText.js | 1 - 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Example/examples/TouchEvents.js b/Example/examples/TouchEvents.js index 4a5effeb..47f278c7 100644 --- a/Example/examples/TouchEvents.js +++ b/Example/examples/TouchEvents.js @@ -85,12 +85,12 @@ class GroupExample extends Component { width="120" viewBox="0 0 240 240" > - - alert('Pressed')}> + alert('Pressed on G')}> + + alert('Pressed on Text')}>H - H diff --git a/elements/Text.js b/elements/Text.js index e4b0372f..154a0323 100644 --- a/elements/Text.js +++ b/elements/Text.js @@ -44,13 +44,11 @@ class Text extends Shape { y = props.dy ? +props.y + (+props.dy) : +props.y; } - return ( - {this.root = ele;}} - {...extractProps({...props, x, y})} - {...extractText(props)} - /> - ); + return {this.root = ele;}} + {...this.extractProps({...props, x, y})} + {...extractText(props)} + />; } } diff --git a/ios/Elements/RNSVGGroup.m b/ios/Elements/RNSVGGroup.m index ac688d58..e9ae04dd 100644 --- a/ios/Elements/RNSVGGroup.m +++ b/ios/Elements/RNSVGGroup.m @@ -54,7 +54,6 @@ return node; } - UIView *view = [node hitTest: point withEvent:event withTransform:matrix]; if (view) { diff --git a/ios/Elements/RNSVGPath.m b/ios/Elements/RNSVGPath.m index 705612b6..b64b1a77 100644 --- a/ios/Elements/RNSVGPath.m +++ b/ios/Elements/RNSVGPath.m @@ -37,8 +37,6 @@ } if ([self getSvgView].responsible) { - NSLog(@"asdasdasdsadas"); - // Add path to hitArea CGMutablePathRef hitArea = CGPathCreateMutableCopy(path); if (self.stroke) { diff --git a/ios/RNSVGRenderable.m b/ios/RNSVGRenderable.m index 2c42abe6..4273097a 100644 --- a/ios/RNSVGRenderable.m +++ b/ios/RNSVGRenderable.m @@ -141,7 +141,7 @@ } return self; } - + CGPathRef hitArea = CGPathCreateCopyByTransformingPath(self.hitArea, &transfrom); CGPathRef clipPath = self.clipPath; BOOL contains = CGPathContainsPoint(hitArea, nil, point, NO); diff --git a/lib/extract/extractText.js b/lib/extract/extractText.js index 514e6284..cf0439a5 100644 --- a/lib/extract/extractText.js +++ b/lib/extract/extractText.js @@ -82,7 +82,6 @@ const anchord = { }; export default function(props) { - return { alignment: anchord[props.textAnchor] || 0, frame: extractFontAndLines(