fix: improve native method spec conformance

This commit is contained in:
Mikael Sand
2019-10-06 17:47:46 +03:00
parent 974f3a8e8e
commit c63f9e29ff
2 changed files with 8 additions and 13 deletions
@@ -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;
}
}
+3 -7
View File
@@ -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)
};
}