Loading...
Loading...
Compare original and translation side by side
varsvarsbackgroundColorrotationXvarsvarsbackgroundColorrotationX"power1.out""power3.inOut""back.out(1.7)""elastic.out(1, 0.3)""none"0.1{ amount: 0.3, from: "center" }{ each: 0.1, from: "random" }falsetrue"auto"-1truefalse"power1.out""power3.inOut""back.out(1.7)""elastic.out(1, 0.3)""none"0.1{ amount: 0.3, from: "center" }{ each: 0.1, from: "random" }falsetrue"auto"-1truefalsetransform| GSAP property | Equivalent |
|---|---|
| translateX/Y/Z (px) |
| translateX/Y in % |
| scale |
| rotate (deg) |
| 3D rotate |
| skew |
| transform-origin |
opacityvisibility: hidden"--hue": 180transformOrigin"360_cw""-170_short""90_ccw""all""+=20""-=10""*=2"transform| GSAP 属性 | 等效属性 |
|---|---|
| translateX/Y/Z (像素) |
| 百分比形式的translateX/Y |
| 缩放 |
| 旋转 (角度) |
| 3D 旋转 |
| 倾斜 |
| 变换原点 |
opacityvisibility: hidden"--hue": 180transformOrigin"360_cw""-170_short""90_ccw""all""+=20""-=10""*=2"gsap.to(".item", {
x: (i, target, targets) => i * 50,
stagger: 0.1,
});gsap.to(".item", {
x: (i, target, targets) => i * 50,
stagger: 0.1,
});power1power4backbouncecircelasticexposine.in.out.inOutpower1power4backbouncecircelasticexposine.in.out.inOutgsap.defaults({ duration: 0.6, ease: "power2.out" });gsap.defaults({ duration: 0.6, ease: "power2.out" });const tween = gsap.to(".box", { x: 100 });
tween.pause();
tween.play();
tween.reverse();
tween.kill();
tween.progress(0.5);
tween.time(0.2);const tween = gsap.to(".box", { x: 100 });
tween.pause();
tween.play();
tween.reverse();
tween.kill();
tween.progress(0.5);
tween.time(0.2);let mm = gsap.matchMedia();
mm.add(
{
isDesktop: "(min-width: 800px)",
reduceMotion: "(prefers-reduced-motion: reduce)",
},
(context) => {
const { isDesktop, reduceMotion } = context.conditions;
gsap.to(".box", {
rotation: isDesktop ? 360 : 180,
duration: reduceMotion ? 0 : 2,
});
},
);let mm = gsap.matchMedia();
mm.add(
{
isDesktop: "(min-width: 800px)",
reduceMotion: "(prefers-reduced-motion: reduce)",
},
(context) => {
const { isDesktop, reduceMotion } = context.conditions;
gsap.to(".box", {
rotation: isDesktop ? 360 : 180,
duration: reduceMotion ? 0 : 2,
});
},
);const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });1"+=0.5""-=0.2""intro""intro+=0.3""<"">""<0.2"tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // same start as .a
tl.to(".c", { opacity: 0 }, "<0.2"); // 0.2s after .b starts1"+=0.5""-=0.2""intro""intro+=0.3""<"">""<0.2"tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // 和.a同时开始
tl.to(".c", { opacity: 0 }, "<0.2"); // 在.b开始后0.2秒开始tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.play("outro");
tl.tweenFromTo("intro", "outro");tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.play("outro");
tl.tweenFromTo("intro", "outro");.play().play()const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);tl.play()tl.pause()tl.reverse()tl.restart()tl.time(2)tl.progress(0.5)tl.kill()tl.play()tl.pause()tl.reverse()tl.restart()tl.time(2)tl.progress(0.5)tl.kill()xyscalerotationopacitywidthheighttopleftxyscalerotationopacitywidthheighttopleftwill-change: transform;will-change: transform;let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),
yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });
container.addEventListener("mousemove", (e) => {
xTo(e.pageX);
yTo(e.pageY);
});let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),
yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });
container.addEventListener("mousemove", (e) => {
xTo(e.pageX);
yTo(e.pageY);
});staggerstaggeraddLabel()gsap.registerPlugin()addLabel()gsap.registerPlugin()