mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-05 07:59:28 +00:00
[ios] Fix gesture responder, onPress/In/Out, onLayout
This commit is contained in:
+20
-1
@@ -10,6 +10,7 @@ import extractResponder from "../lib/extract/extractResponder";
|
||||
import extractViewBox from "../lib/extract/extractViewBox";
|
||||
import Shape from "./Shape";
|
||||
import G from "./G";
|
||||
import _ from "lodash";
|
||||
|
||||
/** @namespace NativeModules.RNSVGSvgViewManager */
|
||||
const RNSVGSvgViewManager = NativeModules.RNSVGSvgViewManager;
|
||||
@@ -24,6 +25,22 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
const gProps = [
|
||||
"font",
|
||||
"transform",
|
||||
"fill",
|
||||
"fillOpacity",
|
||||
"fillRule",
|
||||
"stroke",
|
||||
"strokeWidth",
|
||||
"strokeOpacity",
|
||||
"strokeDasharray",
|
||||
"strokeDashoffset",
|
||||
"strokeLinecap",
|
||||
"strokeLinejoin",
|
||||
"strokeMiterlimit",
|
||||
];
|
||||
|
||||
class Svg extends Shape {
|
||||
static displayName = "Svg";
|
||||
|
||||
@@ -69,6 +86,7 @@ class Svg extends Shape {
|
||||
preserveAspectRatio,
|
||||
style,
|
||||
children,
|
||||
onLayout,
|
||||
...props
|
||||
} = this.props;
|
||||
const stylesAndProps = { ...(style && style.length ? Object.assign({}, ...style) : style), ...props };
|
||||
@@ -92,6 +110,7 @@ class Svg extends Shape {
|
||||
bbWidth={w}
|
||||
bbHeight={h}
|
||||
tintColor={color}
|
||||
onLayout={onLayout}
|
||||
{...extractResponder(props, this)}
|
||||
{...extractViewBox({ viewBox, preserveAspectRatio })}
|
||||
ref={ele => {
|
||||
@@ -106,7 +125,7 @@ class Svg extends Shape {
|
||||
dimensions,
|
||||
]}
|
||||
>
|
||||
<G style={style} {...props}>
|
||||
<G style={style} {...(_.pick(stylesAndProps, gProps))}>
|
||||
{children}
|
||||
</G>
|
||||
</NativeSvgView>
|
||||
|
||||
@@ -73,7 +73,16 @@
|
||||
}];
|
||||
[self setHitArea:[self getPath:context]];
|
||||
self.clientRect = groupRect;
|
||||
self.bounds = groupRect;
|
||||
|
||||
const CGAffineTransform matrix = self.matrix;
|
||||
const CGAffineTransform current = CGContextGetCTM(context);
|
||||
const CGAffineTransform svgToClientTransform = CGAffineTransformConcat(current, self.svgView.invInitialCTM);
|
||||
const CGRect clientRect = CGRectApplyAffineTransform(groupRect, svgToClientTransform);
|
||||
const CGSize clientSize = clientRect.size;
|
||||
|
||||
self.bounds = CGRectMake(0, 0, clientSize.width, clientSize.height);
|
||||
self.frame = CGRectMake(matrix.tx, matrix.ty, clientSize.width, clientSize.height);
|
||||
|
||||
[self popGlyphContext];
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -296,9 +296,16 @@ UInt32 saturate(CGFloat value) {
|
||||
}
|
||||
|
||||
const CGRect pathBounding = CGPathGetBoundingBox(self.path);
|
||||
const CGAffineTransform svgToClientTransform = CGAffineTransformConcat(CGContextGetCTM(context), self.svgView.invInitialCTM);
|
||||
self.clientRect = CGRectApplyAffineTransform(pathBounding, svgToClientTransform);
|
||||
self.bounds = self.clientRect;
|
||||
|
||||
const CGAffineTransform matrix = self.matrix;
|
||||
const CGAffineTransform current = CGContextGetCTM(context);
|
||||
const CGAffineTransform svgToClientTransform = CGAffineTransformConcat(current, self.svgView.invInitialCTM);
|
||||
const CGRect clientRect = CGRectApplyAffineTransform(pathBounding, svgToClientTransform);
|
||||
const CGSize clientSize = clientRect.size;
|
||||
|
||||
self.clientRect = clientRect;
|
||||
self.bounds = CGRectMake(0, 0, clientSize.width, clientSize.height);
|
||||
self.frame = CGRectMake(matrix.tx, matrix.ty, clientSize.width, clientSize.height);
|
||||
|
||||
CGPathDrawingMode mode = kCGPathStroke;
|
||||
BOOL fillColor = NO;
|
||||
|
||||
Reference in New Issue
Block a user