I am using the below code to do a transform animation:
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.
]}}>
Currently, the transform-origin (<- not actually available in react native) is the center. For the animation, the component scales from the center, so it looks like it is "expanding" from the center. I want it to "expand" from the top (i.e. make the transform origin the top of the component...I think).
I found a method that simulates the 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);
}
But I am not sure what matrices to use to affect the component the way I want. I have some understanding of transformation matrices, but only for translating and rotating - I am not sure how to affect the origin of a scale transform.
For anyone looking to do some digging, thanks: https://en.wikipedia.org/wiki/Transformation_matrix