我有这个功能:
function anim(params) {
var default_opts = {
parent: ".blur-word",
element: ".blur-word__el",
time: 1,
initial_delay: 1.5,
stagger_delay: 0.2,
easing: Sine.easeOut,
};
params = $.extend({}, default_opts, params);
var t = params.time,
init_delay = params.initial_delay,
stag_delay = params.stagger_delay,
ease = params.easing;
$(params.parent).each(function() {
var $element = $(this).find(params.element),
tl = new TimelineMax({ paused: true });
TweenMax.set($element, { x: -50, opacity: 0 });
tl.staggerTo($element, t, { x: 100, opacity: 1, delay: init_delay, ease: ease, }, stag_delay);
});
}
所以当我第一次运行该函数时,我希望暂停每个匹配元素的gsap时间轴:anim();
然后我想运行时间轴tl.play()
之前通过再次调用该函数暂停了:anim.play_anim()
包含此tl.play()
;
我想我必须在.each函数中使用模块函数但是如何?
在哪里以及如何定义play_anim();
函数?