Jump to content


Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes. For example, gsap.getTweensOf(myObject) returns an array of all tweens of myObject, even tweens that haven’t begun yet. gsap.getTweensOf([myObject1, myObject2]); will return a condensed array of the tweens of myObject1 plus all the tweens of myObject2 combined into one array with duplicates removed.

Since the method only finds tweens that haven’t been released for garbage collection, if you create a tween and then let it finish and then a while later try to find it with getTweensOf(), it may not be found because it was released by the engine for garbage collection. Remember, one of the best parts of GSAP is that it saves you from the headache of managing garbage collection. Otherwise, you’d need to manually dispose each tween you create, making things much more cumbersome.

  1. gsap.to(myObject1, {duration: 1, x: 100});
  2. gsap.to(myObject2, {duration: 1, x: 100});
  3. gsap.to([myObject1, myObject2], {duration: 1, opacity: 0});
  4. var a1 = gsap.getTweensOf(myObject1); //finds 2 tweens
  5. var a2 = gsap.getTweensOf([myObject1, myObject2]); //finds 3 tweens
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.