Tween Kill

  • Killing an animation means it’s immediately stopped, removed from its parent timeline, and released for garbage collection.
  • kill()

    kill(target:Object, propertiesList:String): self

    Stops (or “kills”) the animation completely or partially, depending on the parameters provided.
    Killing an animation means it’s immediately stopped, removed from its parent timeline, and released for garbage collection.


    Parameters

    • target (Object, default = null)

      • Defines which target(s) to affect.

      • To kill only the animation(s) related to a specific target, pass that object:
        kill(myObject)

      • To target multiple objects:
        kill([myObject1, myObject2])

      • If omitted, all targets of the animation are affected.

    • propertiesList (String, default = "all")

      • A comma-separated list of property names to stop animating (e.g., "x,y,opacity").

      • If "all", null, or omitted, every property is killed for the specified target(s).


    Returns

    • self – returns the animation instance for easy method chaining.


    Details

    Calling kill() with no parameters stops the entire animation immediately, removes it from its timeline, clears its tweens, and frees it for garbage collection.

    You can also target specific elements or specific animated properties to partially kill an animation.

Example

// Kill the entire animation:
animation.kill();
animation = null; // Optional: remove reference

// Kill all animations related to a single target:
animation.kill(myObject);

// Kill only specific properties ("x" and "y") of all targets:
animation.kill(null, "x,y");

// Kill only "x" and "y" properties for a single target:
animation.kill(myObject, "x,y");

// Kill only the "opacity" animation for multiple targets:
animation.kill([myObject1, myObject2], "opacity");

// You can also use a CSS selector-style string for DOM targets:
animation.kill(".box", "opacity");