Fixes for animation of width and height

This commit is contained in:
Mikael Sand
2018-10-10 22:35:25 +03:00
parent b13e164e22
commit e307eeee57
8 changed files with 75 additions and 15 deletions
@@ -13,6 +13,9 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.RectF; import android.graphics.RectF;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
/** /**
@@ -41,15 +44,22 @@ class RectShadowNode extends RenderableShadowNode {
} }
@ReactProp(name = "rectwidth") @ReactProp(name = "rectwidth")
public void setWidth(String width) { public void setWidth(Dynamic width) {
mW = width; if (width.getType() == ReadableType.String) {
mW = width.asString();
} else {
mW = String.valueOf(width.asDouble());
}
markUpdated(); markUpdated();
} }
@ReactProp(name = "rectheight") @ReactProp(name = "rectheight")
public void setHeight(String height) { public void setHeight(Dynamic height) {
mH = height; if (height.getType() == ReadableType.String) {
mH = height.asString();
} else {
mH = String.valueOf(height.asDouble());
}
markUpdated(); markUpdated();
} }
@@ -304,13 +304,13 @@ class RenderableViewManager<T extends VirtualNode> extends ViewGroupManager<Rend
} }
@ReactProp(name = "rectwidth") @ReactProp(name = "rectwidth")
public void setWidth(RenderableView<RectShadowNode> node, String width) { public void setWidth(RenderableView<RectShadowNode> node, Dynamic width) {
node.shadowNode.setWidth(width); node.shadowNode.setWidth(width);
} }
@ReactProp(name = "rectheight") @ReactProp(name = "rectheight")
public void setHeight(RenderableView<RectShadowNode> node, String height) { public void setHeight(RenderableView<RectShadowNode> node, Dynamic height) {
node.shadowNode.setHeight(height); node.shadowNode.setHeight(height);
} }
+8 -2
View File
@@ -31,8 +31,14 @@ export default class extends Shape {
preserveAspectRatio: "xMidYMid meet", preserveAspectRatio: "xMidYMid meet",
}; };
setNativeProps = (...args) => { setNativeProps = (props) => {
this.root.setNativeProps(...args); if (props.width) {
props.imagewidth = `${props.width}`;
}
if (props.height) {
props.imageheight = `${props.height}`;
}
this.root.setNativeProps(props);
}; };
render() { render() {
+13
View File
@@ -22,6 +22,16 @@ export default class extends Component {
]), ]),
}; };
setNativeProps = (props) => {
if (props.width) {
props.maskwidth = `${props.width}`;
}
if (props.height) {
props.maskheight = `${props.height}`;
}
this.root.setNativeProps(props);
};
render() { render() {
const { props } = this; const { props } = this;
const { const {
@@ -48,6 +58,9 @@ export default class extends Component {
return ( return (
<RNSVGMask <RNSVGMask
ref={ele => {
this.root = ele;
}}
name={id} name={id}
x={`${x}`} x={`${x}`}
y={`${y}`} y={`${y}`}
+13
View File
@@ -25,6 +25,16 @@ export default class extends Component {
preserveAspectRatio: PropTypes.string, preserveAspectRatio: PropTypes.string,
}; };
setNativeProps = (props) => {
if (props.width) {
props.patternwidth = `${props.width}`;
}
if (props.height) {
props.patternheight = `${props.height}`;
}
this.root.setNativeProps(props);
};
render() { render() {
const { props } = this; const { props } = this;
const { const {
@@ -53,6 +63,9 @@ export default class extends Component {
return ( return (
<RNSVGPattern <RNSVGPattern
ref={ele => {
this.root = ele;
}}
name={id} name={id}
x={`${x}`} x={`${x}`}
y={`${y}`} y={`${y}`}
+8 -2
View File
@@ -28,8 +28,14 @@ export default class extends Shape {
ry: 0 ry: 0
}; };
setNativeProps = (...args) => { setNativeProps = (props) => {
this.root.setNativeProps(...args); if (props.width) {
props.rectwidth = `${props.width}`;
}
if (props.height) {
props.rectheight = `${props.height}`;
}
this.root.setNativeProps(props);
}; };
render() { render() {
+8 -2
View File
@@ -62,8 +62,14 @@ class Svg extends Shape {
this.root.measureLayout(...args); this.root.measureLayout(...args);
}; };
setNativeProps = (...args) => { setNativeProps = (props) => {
this.root.setNativeProps(...args); if (props.width) {
props.bbWidth = `${props.width}`;
}
if (props.height) {
props.bbHeight = `${props.height}`;
}
this.root.setNativeProps(props);
}; };
toDataURL = callback => { toDataURL = callback => {
+8 -2
View File
@@ -22,8 +22,14 @@ export default class extends Shape {
height: 0 height: 0
}; };
setNativeProps = (...args) => { setNativeProps = (props) => {
this.root.setNativeProps(...args); if (props.width) {
props.usewidth = `${props.width}`;
}
if (props.height) {
props.useheight = `${props.height}`;
}
this.root.setNativeProps(props);
}; };
render() { render() {