跳过主要内容

getChildren

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

返回一个包含此时间轴内嵌套的所有补间动画和/或时间轴的数组。

参数

  • 嵌套:布尔值

    (默认值 =true) - 决定是否返回嵌套在时间线内的补间动画和/或时间线。如果你只想获取“顶层”的补间动画和时间线,请将此值设为false.

  • 补间动画:布尔值

    (默认值 =true) - 决定结果中是否包含补间动画。

  • 时间轴:布尔值

    (默认值 =true) - 决定结果中是否包含时间线。

  • ignoreBeforeTime: 数值

    Number(默认值 =-Infinity) - 所有开始时间小于该值的子项将会被忽略。

返回值 : 数组

一个包含子补间动画和时间线的数组。

细节

返回一个数组,其中包含此时间线中符合给定条件的所有嵌套补间动画和/或时间线。回调函数(延迟调用)被视为持续时间为零的补间动画。

//first, let's set up a master timeline and nested timeline:
var master = gsap.timeline({ defaults: { duration: 1 } }),
nested = gsap.timeline();

//drop 2 tweens into the nested timeline
nested.to("#e1", { duration: 1, x: 100 }).to("#e2", { duration: 2, y: 200 });

//drop 3 tweens into the master timeline
master
.to("#e3", { top: 200 })
.to("#e4", { left: 100 })
.to("#e5", { backgroundColor: "red" });

//nest the timeline:
master.add(nested);

//get only the direct children of the master timeline:
var children = master.getChildren(false, true, true);

console.log(children.length); //"3" (2 tweens and 1 timeline)

//get all of the tweens/timelines (including nested ones) that occur AFTER 0.5 seconds
children = master.getChildren(true, true, true, 0.5);

console.log(children.length); //"5" (4 tweens and 1 timeline)

//get only tweens (not timelines) of master (including nested tweens):
children = master.getChildren(true, true, false);

console.log(children.length); //"5" (5 tweens)
无噪 Logo
无噪文档
中文文档 · 复刻官网
查看所有 ↗