最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to reset original positions after playing in TimelineMax (GSAP) - Stack Overflow

programmeradmin7浏览0评论

I'm playing my animations like this,

tl = new TimelineMax({paused:true});

tl.to(DOM_ELEMENT_TOP,1,{left:100},ease:Linear.easeIn);
tl.to(DOM_ELEMENT_BOTTOM,1,{top:100},ease:Linear.easeIn);

tl.play();

How do i reset the DOM elements to their original positions after the animation has finished playing?

I want to do this without reversing the animation itself (obviously!)

I'm playing my animations like this,

tl = new TimelineMax({paused:true});

tl.to(DOM_ELEMENT_TOP,1,{left:100},ease:Linear.easeIn);
tl.to(DOM_ELEMENT_BOTTOM,1,{top:100},ease:Linear.easeIn);

tl.play();

How do i reset the DOM elements to their original positions after the animation has finished playing?

I want to do this without reversing the animation itself (obviously!)

Share Improve this question asked Apr 6, 2015 at 12:00 wolfgangwolfgang 7,83914 gold badges49 silver badges72 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Looks like there are some typos in your code - the ease belongs inside the vars object:

tl.to(DOM_ELEMENT_TOP, 1, {left:100, ease:Linear.easeIn});
tl.to(DOM_ELEMENT_BOTTOM, 1, {top:100, ease:Linear.easeIn});

And then if you want to revert things to where they started, you can simply jump to the beginning like:

tl.pause(0);

Or, if you want to literally clear the top/left property from the inline CSS, you can do:

TweenLite.set(DOM_ELEMENT_TOP, {clearProps:"left"});
TweenLite.set(DOM_ELEMENT_BOTTOM, {clearProps:"top"});
发布评论

评论列表(0)

  1. 暂无评论