Capítulo 6 de 411
A modifiers function intercepts the value GSAP is about to apply to a property on every tick, letting you run custom logic (snapping, clamping, wrapping) and return the value that actually gets applied.
(value, target) => newValue — value is the about-to-be-applied value (number or string, depending on the property), target is the animated object itself.roundProps and a custom modifier on the same property, but you can replicate rounding yourself with Math.round() inside a modifier.// wrap x between 0 and 100 while animating toward 500
gsap.to(".box", {
x: 500,
modifiers: {
x: (x) => gsap.utils.wrap(0, 100, parseFloat(x)) + "px",
},
});
wrap) to build a seamless looping effect, the same technique behind carousel-style infinite scroll.roundProps and a modifier on the same property: they use the same underlying mechanism and conflict; do the rounding inside the modifier instead.scaleX/scaleY (not scale) and rotation (not rotationZ) inside modifiers..to() with a modifier and stagger can implement a seamless repeating carousel without duplicating assets.