终止应用于给定目标子元素的所有补间动画
你可以通过使用此函数来终止所有属于给定目标子元素的补间动画:
演示
function killChildTweensOf(ancestor) {
ancestor = gsap.utils.toArray(ancestor)[0];
gsap.globalTimeline
.getChildren(true, true, false)
.forEach((tween) =>
tween
.targets()
.forEach((e) => e.nodeType && ancestor.contains(e) && tween.kill(e))
);
}