Transform in gsap

Transform Property

行为 gsap css
—- x: 100 transform: translateX(100px)
—- y: 100 transform: translateY(100px)
位移百分比 xPercent: 50 transform: translateX(50%)
—- yPercent: 50 transform: translateY(50%)
—- scale: 2 transform: scale(2)
—- scaleX: 2 transform: scaleX(2)
—- scaleY: 2 transform: scaleY(2)
—- rotation: 90 transform: rotate(90deg)
—- rotation: “1.25rad” Using Radians - no CSS alternative
斜切 skew: 30 transform: skew(30deg)
—- skewX: 30 transform: skewX(30deg)
—- skewY: “1.23rad” Using Radians - no CSS alternative
—- transformOrigin: “center 40%” transform-origin: center 40%
—- opacity: 0 adjust the elements opacity
—- autoAlpha: 0 shorthand for opacity & visibility
动画时长 duration: 1 animation-duration: 1s
无线循环 repeat: -1 animation-iteration-count: infinite
重复次数 repeat: 2 animation-iteration-count: 2
延迟播放 delay: 2 animation-delay: 2
往复循环 yoyo: true animation-direction: alternate

Unit

长度

1
2
3
4
x: 200 // 默认为px
x: '+=200' // 相对数值
x: '40vw' // 字符串单位自动转换
x: () => window.innerWidth/2 //函数返回值

角度

1
2
3
rotation: 360 // 默认为deg
rotation: '1.5rad' // 弧度单位
// 不支持grad和turn

Ease Animation


本文作者: 孟 虎
本文链接: https://menghu1994.github.io/blog/2024/04/Animation/GSAP/baseTransform/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!