Files
motiondivision-motion/packages/motion-dom/src/projection/utils/has-transform.ts
T
dualfroz 2e01f31175 Keep rotateZ on elements with a layout animation
The projection pipeline handled rotate, rotateX and rotateY but not
rotateZ, so a layout or shared layout animation silently dropped it from
the generated transform and never mixed it between lead and follow.
2026-09-11 23:06:36 +02:00

37 lines
961 B
TypeScript

import { type AnyResolvedKeyframe } from "../../animation/types"
import { ResolvedValues } from "../../render/types"
function isIdentityScale(scale: AnyResolvedKeyframe | undefined) {
return scale === undefined || scale === 1
}
export function hasScale({ scale, scaleX, scaleY }: ResolvedValues) {
return (
!isIdentityScale(scale) ||
!isIdentityScale(scaleX) ||
!isIdentityScale(scaleY)
)
}
export function hasTransform(values: ResolvedValues) {
return (
hasScale(values) ||
has2DTranslate(values) ||
values.z ||
values.rotate ||
values.rotateX ||
values.rotateY ||
values.rotateZ ||
values.skewX ||
values.skewY
)
}
export function has2DTranslate(values: ResolvedValues) {
return is2DTranslate(values.x) || is2DTranslate(values.y)
}
function is2DTranslate(value: AnyResolvedKeyframe | undefined) {
return value && value !== "0%"
}