@GreenSock Thank you very much for your help!
I would like to take this opportunity to ask you. A little off topic, I hope you don’t mind.
For some animations with CSS transformations, we explicitly set will-change: transform to create a composite layer that will be processed on the GPU and eliminate jitter, especially on text. Of course, after performing the transformations, will-change must be returned to the auto in order to free up memory.
I do it like this:
const tl = new gsap.timeline();
tl.set(elements, {
willChange: 'transform',
}, 0);
tl.fromTo(elements, {
y: '110%',
scaleY: 1.5,
transformOrigin: 'top top',
}, {
y: '0%',
scaleY: 1,
transformOrigin: 'top top',
duration: 2,
stagger: {amount: 0.3},
ease: 'expo.out',
}, 0);
tl.set(elements, {
willChange: 'auto',
});
return tl;
Some developers I know do it like this:
const tl = new gsap.timeline();
const wc = [...elements, ...moreElements];
tl.set(wc, {
willChange: 'transform',
}, 0);
tl.fromTo(elements, {
y: '110%',
scaleY: 1.5,
transformOrigin: 'top top',
}, {
y: '0%',
scaleY: 1,
transformOrigin: 'top top',
duration: 2,
stagger: {amount: 0.1},
ease: 'expo.out',
}, 0);
tl.fromTo(moreElements, {
y: '110%',
}, {
y: '0%',
duration: 2,
stagger: {amount: 0.3},
ease: 'expo.out',
}, 0.2);
tl.set(wc, {
willChange: 'auto',
});
return tl;
Unfortunately, I did not find a built-in mechanism in GSAP to automate this routine process. There is a Force3D property, but it’s not quite the same. It would be very cool if GSAP could do this automatically, for example:
tl.from(elements, {
y: '110%',
scaleY: 1.5,
duration: 2,
stagger: {amount: 0.3},
ease: 'expo.out',
autoWillChange: true, // or force3D: 'will-change'
});
Here are some videos where you can see the difference when using will-change.
The difference is clearly visible at the “We would love to talk!” caption.
No will-change: https://www.dropbox.com/scl/fi/sau2hmz055zuylq67pqsq/no-will-change.mp4?rlkey=4buyngxk359nxioxyc3l4i07a&dl=0
Will-change is set: https://www.dropbox.com/scl/fi/8fkxxh6j6w79fn9bcjdy0/will-change-set.mp4?rlkey=ycv5aq4qir6vpzvznn8frdur7&dl=0
Force3D is true: https://www.dropbox.com/scl/fi/ww2ienyi4kl6067xz4t5u/force3D-true.mp4?rlkey=ssx678lh215pfyk73t3nc8xgj&dl=0
Once again, sorry for being off-topic, I probably should have posted this as a future request.