mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-08-16 02:44:58 +00:00
fix: improve native method spec conformance
This commit is contained in:
@@ -159,6 +159,7 @@ class RNSVGRenderableManager extends ReactContextBaseJavaModule {
|
||||
return null;
|
||||
}
|
||||
|
||||
float scale = svg.mScale;
|
||||
Matrix ctm = new Matrix(svg.mCTM);
|
||||
Matrix invViewBoxMatrix = svg.getSvgView().mInvViewBoxMatrix;
|
||||
ctm.preConcat(invViewBoxMatrix);
|
||||
@@ -171,8 +172,8 @@ class RNSVGRenderableManager extends ReactContextBaseJavaModule {
|
||||
result.putDouble("b", values[Matrix.MSKEW_Y]);
|
||||
result.putDouble("c", values[Matrix.MSKEW_X]);
|
||||
result.putDouble("d", values[Matrix.MSCALE_Y]);
|
||||
result.putDouble("e", values[Matrix.MTRANS_X]);
|
||||
result.putDouble("f", values[Matrix.MTRANS_Y]);
|
||||
result.putDouble("e", values[Matrix.MTRANS_X] / scale);
|
||||
result.putDouble("f", values[Matrix.MTRANS_Y] / scale);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -186,8 +187,6 @@ class RNSVGRenderableManager extends ReactContextBaseJavaModule {
|
||||
|
||||
float[] values = new float[9];
|
||||
svg.mCTM.getValues(values);
|
||||
|
||||
SvgView root = svg.getSvgView();
|
||||
float scale = svg.mScale;
|
||||
|
||||
WritableMap result = Arguments.createMap();
|
||||
@@ -195,8 +194,8 @@ class RNSVGRenderableManager extends ReactContextBaseJavaModule {
|
||||
result.putDouble("b", values[Matrix.MSKEW_Y]);
|
||||
result.putDouble("c", values[Matrix.MSKEW_X]);
|
||||
result.putDouble("d", values[Matrix.MSCALE_Y]);
|
||||
result.putDouble("e", values[Matrix.MTRANS_X] + root.getLeft() / scale);
|
||||
result.putDouble("f", values[Matrix.MTRANS_Y] + root.getTop() / scale);
|
||||
result.putDouble("e", values[Matrix.MTRANS_X] / scale);
|
||||
result.putDouble("f", values[Matrix.MTRANS_Y] / scale);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,18 +228,14 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getScreenCTM:(nonnull NSNumber *)reactTag
|
||||
}
|
||||
|
||||
RNSVGRenderable *svg = (RNSVGRenderable *)view;
|
||||
RNSVGSvgView* root = svg.svgView;
|
||||
CGAffineTransform viewbox = [root getViewBoxTransform];
|
||||
CGAffineTransform ctm = CGAffineTransformConcat(svg.ctm, viewbox);
|
||||
CGPoint offset = [root convertPoint:CGPointZero toView:svg.window];
|
||||
|
||||
CGAffineTransform ctm = svg.ctm;
|
||||
return @{
|
||||
@"a":@(ctm.a),
|
||||
@"b":@(ctm.b),
|
||||
@"c":@(ctm.c),
|
||||
@"d":@(ctm.d),
|
||||
@"e":@(ctm.tx + offset.x),
|
||||
@"f":@(ctm.ty + offset.y)
|
||||
@"e":@(ctm.tx),
|
||||
@"f":@(ctm.ty)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user