GSAP transforms
- Transformations are properties that can increase and decrease the size of the selected elements.
Transforms
GSAP offers built-in aliases for transform properties that are cross-browser compatible, high-performance, and more reliable than manually animating the CSS
transformstring.
gsap.to(element, {
// Instead of writing this in CSS:
// transform: "translate(-50%, -50%)"
xPercent: -50,
yPercent: -50,
});
In regular CSS, the order of transform functions (like
translate,scale,rotate, etc.) affects the final result — changing the sequence can completely alter the transformation.
However, GSAP standardizes this by always applying transforms in a fixed, consistent order for predictable results:Order of application:
-
Translation (
x,y,z) -
Scale
-
RotationX
-
RotationY
-
Skew
-
Rotation (same as
rotationZ)
This ensures that your transforms behave the same way every time — no surprises, no browser inconsistencies.
-
GSAP Property Equivalent CSS / Description x: 100transform: translateX(100px)y: 100transform: translateY(100px)xPercent: 50transform: translateX(50%)yPercent: 50transform: translateY(50%)scale: 2transform: scale(2)scaleX: 2transform: scaleX(2)scaleY: 2transform: scaleY(2)rotation: 90transform: rotate(90deg)rotation: "1.25rad"transform: rotate(1.25rad)skew: 30transform: skew(30deg)skewX: 30transform: skewX(30deg)skewY: "1.23rad"transform: skewY(1.23rad)transformOrigin: "center 40%"transform-origin: center 40%opacity: 0Adjusts the element’s opacity autoAlpha: 0Shorthand for opacity + visibility (sets visibility: hidden when opacity = 0) duration: 1animation-duration: 1srepeat: -1animation-iteration-count: infiniterepeat: 2animation-iteration-count: 3delay: 2animation-delay: 2syoyo: trueanimation-direction: alternate(makes the animation reverse every other cycle)