Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

Timeline

.getChildren()

.getChildren( nested:Boolean, tweens:Boolean, timelines:Boolean, ignoreBeforeTime:Number ) : Array

Returns an array containing all the tweens and/or timelines nested in this timeline.

Parameters

nested: Boolean

(default = true) — Determines whether or not tweens and/or timelines that are inside nested timelines should be returned. If you only want the “top level” tweens and timelines, set this to false.

tweens: Boolean

(default = true) — Determines whether or not tweens should be included in the results.

timelines: Boolean

(default = true) — Determines whether or not timelines should be included in the results.

ignoreBeforeTime: Number

Number (default = -9999999999) — All children with start times that are less than this value will be ignored.

Returns : Array

An Array of active tweens and timelines.

Details

Returns an array containing all the tweens and/or timelines nested in this timeline. Callbacks (delayed calls) are considered zero-duration tweens.

  1. //first, let's set up a master timeline and nested timeline:
  2. var master = gsap.timeline({defaults: {duration: 1}}),
  3. nestedTimeline = gsap.timeline();
  4. //drop 2 tweens into the nested timeline
  5. nestedTimeline.to("#e1", {duration: 1, x: 100})
  6. .to("#e2", {duration: 2, y: 200});
  7. //drop 3 tweens into the master timeline
  8. master.to("#e3", {top: 200})
  9. .to("#e4", {left: 100})
  10. .to("#e5", {backgroundColor: "red"});
  11. //nest the timeline:
  12. master.add(nestedTimeline);
  13. //now let's get only the direct children of the master timeline:
  14. var children = master.getChildren(false, true, true, 0);
  15. console.log(children.length); //"3" (2 tweens and 1 timeline)
  16. //get all of the tweens/timelines (including nested ones) that occur AFTER 0.5 seconds
  17. children = master.getChildren(true, true, true, 0.5);
  18. console.log(children.length); //"5" (4 tweens and 1 timeline)
  19. //get only tweens (not timelines) of master (including nested tweens):
  20. children = master.getChildren(true, true, false, 0);
  21. console.log(children.length); //"5" (5 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.
×