【发布时间】:2019-02-22 08:35:06
【问题描述】:
我正在使用下面的代码来做一个变换动画:
transform: [
// scaleX, scaleY, scale, theres plenty more options you can find online for this.
{ scaleY: this.state.ViewScale } // this would be the result of the animation code below and is just a number.
]}}>
目前,transform-origin(
我找到了一个模拟transform-origin css的方法:
transformOrigin(matrix, origin) {
const { x, y, z } = origin;
const translate = MatrixMath.createIdentityMatrix();
MatrixMath.reuseTranslate3dCommand(translate, x, y, z);
MatrixMath.multiplyInto(matrix, translate, matrix);
const untranslate = MatrixMath.createIdentityMatrix();
MatrixMath.reuseTranslate3dCommand(untranslate, -x, -y, -z);
MatrixMath.multiplyInto(matrix, matrix, untranslate);
}
但我不确定使用什么矩阵来以我想要的方式影响组件。我对变换矩阵有一些了解,但仅用于平移和旋转 - 我不确定如何影响 scale 变换的原点。
对于任何想要挖掘的人,谢谢:https://en.wikipedia.org/wiki/Transformation_matrix
【问题讨论】:
标签: javascript css react-native matrix transform