overwrite
overwrite is a GSAP tween property that decides what happens when a new tween targets a property another tween is already animating. Set it to `"auto"` and GSAP kills only the conflicting parts of other active tweens on the same target, so the new tween takes over cleanly instead of two tweens fighting over the same value frame by frame.
Updated June 30, 2026
How overwrite works
When two tweens animate the same property of the same element at the same time, GSAP has to decide who wins. By default it lets both run, and they fight: each one writes its own value every frame and the element jitters or snaps to whichever rendered last. overwrite is the property that resolves that conflict.
It takes one of three values, and the gap between them matters in practice:
false(the default): both tweens keep running. They compete on every frame, which is where the snapping and jitter come from.true: the new tween immediately kills every other active tween of the same target, including properties that don't overlap."auto": when the new tween first renders, it kills only the individual overlapping properties in other active tweens of the same target. The non-conflicting tweens keep going.
Why this is a performance entry
overwrite: "auto" doesn't make a tween composited, but it stops you paying for two tweens when you only meant to run one.Reach for overwrite: "auto" when
- Hover-in and hover-out tweens target the same property (a button pulls toward the cursor on
mouseenter, springs back onmouseleave, both animatingx/y) - A panel or drawer can be re-toggled before its open/close tween has finished
- A click handler can fire faster than the tween it starts (rapid taps on the same element)
- Any event-driven
gsap.toon a property a previous tween of the same element might still be animating
Use something else when
- You want a hard reset that kills ALL tweens of the target, overlapping or not, use
overwrite: true - The events fire at mousemove or scroll rate, use
gsap.quickToinstead. It reuses one tween and updates its end value, so no second tween is ever spawned and there's nothing to overwrite - Open and close are true mirrors of each other, build one reversible timeline and call
play()/reverse(). There are no competing tweens to resolve - The tweens animate genuinely different properties (one does
x, another doesopacity) and should run together, leave it on thefalsedefault
Used in these Annnimate components
Both of these run on real cursor-driven work where a new tween fires while the last one is still going:
- The Custom Cursor sets
overwrite: trueon its follow tween, so every new position tween kills the previous one and the cursor never lags behind a stack of stale tweens as the mouse moves - The Magnetic Button runs the magnetic pull on
mousemoveand the spring-back onmouseleave, both on the samex/y. When the cursor leaves mid-pull, the release tween and the pull tween are competing for the same property, which is exactly the conflictoverwriteexists to settle
Watch the global default
gsap.defaults({ overwrite: "auto" }) to apply it everywhere, but be deliberate about it. Once it's global, a tween that was intentionally meant to layer on top of another (different properties, same element) can silently get killed. Prefer setting overwrite per tween where the conflict actually is.See it running in production
Common questions
- What's the difference between overwrite: true and overwrite: "auto"?
truekills every other active tween of the same target the moment the new tween starts, even tweens animating properties that don't overlap."auto"only kills the specific overlapping properties, and it does it when the new tween first renders rather than at creation."auto"is the safer pick most of the time because it leaves unrelated tweens alone. Usetruewhen you genuinely want a clean slate on that element.- Why does my hover animation snap or jitter when I move the mouse fast?
- Almost always two tweens fighting over the same property with the default
overwrite: false. The enter tween hasn't finished when the leave tween starts, so both writex/yevery frame and the element snaps between their values. Addoverwrite: "auto"to the tweens, or for mousemove-rate updates switch togsap.quickToso there's only ever one tween. - Does overwrite kill the whole timeline or just the tween?
- It works on individual tweens of the same target, not timelines. A tween with
overwrite: "auto"kills the conflicting parts of other active TWEENS on that element. It won't reach into a timeline and stop it. If you need to stop a timeline, control the timeline directly withpause()/kill(). - Should I set overwrite globally with gsap.defaults?
- You can, with
gsap.defaults({ overwrite: "auto" }), and some teams do. The risk is that a tween you meant to layer on top of another one (animating a different property on the same element) can get killed once the default is on. It's usually cleaner to setoverwriteper tween at the spot where the conflict actually happens, so the behavior is visible in the code that needs it. - overwrite vs killTweensOf, which should I use?
overwriteis automatic and lives on the new tween, GSAP resolves the conflict for you as that tween starts.gsap.killTweensOf(target)is manual and imperative, you call it yourself before starting the next tween. Useoverwritefor the common event-driven case (hover, click, drag). Reach forkillTweensOfwhen you need to clear tweens at a moment that isn't tied to starting a new one, like on cleanup or a state reset.
