Jump to content
GreenSock

TimelineMax

.kill()

.kill( vars:Object, target:Object ) : *

Kills the animation entirely or in part depending on the parameters.

Parameters

vars: Object

(default = null) — To kill only specific properties, use a generic object containing enumerable properties corresponding to the ones that should be killed, like {x:true, y:true}. The values assigned to each property of the object don’t matter – the sole purpose of the object is for iteration over the named properties (in this case, x and y). If no object (or null) is defined, ALL properties will be killed.

target: Object

(default = null) — To kill only aspects of the animation related to a particular target (or targets), reference it here. For example, to kill only parts having to do with myObject, do kill(null, myObject) or to kill only parts having to do with myObject1 andmyObject2, do kill(null, [myObject1, myObject2]). If no target is defined, ALL targets will be affected.

Returns : *

self (makes chaining easier)

Details

Kills the animation entirely or in part depending on the parameters. Simply calling kill() (omitting the parameters) will immediately stop the animation and release it for garbage collection. To kill only particular tweening properties of the animation, use the first parameter which should be a generic object with enumerable properties corresponding to those that should be killed, like {x:true, y:true}. The second parameter allows you to define a target (or array of targets) to affect.

Note: the values assigned to each property of the vars parameter object don't matter - the sole purpose of the object is for iteration over the named properties. In other words, {x:true, y:true} would produce the same results as {x:false, y:false}.

//kill the entire animation:
myAnimation.kill();

//kill only the "x" and "y" properties of the animation (all targets):
myAnimation.kill({x:true, y:true});

//kill all parts of the animation related to the target "myObject" (if the tween has multiple targets, the others will not be affected):
myAnimation.kill(null, myObject);

//kill only the "x" and "y" properties of animations of the target "myObject":
myAnimation.kill({x:true, y:true}, myObject);

//kill only the "opacity" properties of animations of the targets "myObject1" and "myObject2":
myAnimation.kill({opacity:true}, [myObject1, myObject2]);
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×