mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 22:43:10 +08:00
Deprecate transformMatrix and decomposedMatrix
Summary:
transformMatrix only worked on iOS and there is an equivalent API that (mostly)
works cross platform.
decomposedMatrix could technically be passed on Android but it wasn't document and explicitly flagged as not working.
My goal is to deprecate both uses and then the only supported API is the `transform: [{ matrix: ... }]` form.
The only difference is that on Android the matrix gets decomposed.
Currently there is some special cased magic that renames transform -> transformMatrix or decomposedMatrix depending on platform.
https://github.com/facebook/react/blob/master/src/renderers/native/ReactNative/ReactNativeAttributePayload.js#L50
Therefore I'm adding an alias for both native platforms called just "transform".
Next I'll swap over the JS to always target the name "transform". The only difference is how the value is marshalled over the bridge in processTransform.
To do this, I have to clean up a few callers. Mostly that's just swapping to the new API.
For buildInterpolator this is a bit trickier but this fixes it for all our use cases (which is only the Navigator in AdsManager).
Reviewed By: vjeux
Differential Revision: D3239960
fb-gh-sync-id: 838edb6644c6cdd0716834f712042f226ff3136f
fbshipit-source-id: 838edb6644c6cdd0716834f712042f226ff3136f
This commit is contained in:
committed by
Facebook Github Bot 5
parent
7e9720f0ae
commit
373537b281
@@ -25,6 +25,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
private static final String PROP_DECOMPOSED_MATRIX_SCALE_Y = "scaleY";
|
||||
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_X = "translateX";
|
||||
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_Y = "translateY";
|
||||
private static final String PROP_TRANSFORM = "transform";
|
||||
private static final String PROP_OPACITY = "opacity";
|
||||
private static final String PROP_ELEVATION = "elevation";
|
||||
private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
|
||||
@@ -51,6 +52,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
view.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
// TODO: t11041683 Remove this duplicate property name.
|
||||
@ReactProp(name = PROP_DECOMPOSED_MATRIX)
|
||||
public void setDecomposedMatrix(T view, ReadableMap decomposedMatrix) {
|
||||
if (decomposedMatrix == null) {
|
||||
@@ -60,6 +62,15 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_TRANSFORM)
|
||||
public void setTransform(T view, ReadableMap decomposedMatrix) {
|
||||
if (decomposedMatrix == null) {
|
||||
resetTransformMatrix(view);
|
||||
} else {
|
||||
setTransformMatrix(view, decomposedMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_OPACITY, defaultFloat = 1.f)
|
||||
public void setOpacity(T view, float opacity) {
|
||||
view.setAlpha(opacity);
|
||||
|
||||
Reference in New Issue
Block a user