Jump to content
uomopalese

Repeat a little function onComplete.

Recommended Posts

HI, I'm really new to all this, I just looked at the 'Getting Started' video.

My question is: is this the right way to get that result (the blue line shrink from left to right in an infinite loop) or there is another/better way to achive this result?

At first i tried this code:

TweenMax.to(".light", 0.8, {left:0, delay:1.7, ease:Power0.easeOut});
TweenMax.to(".dark", 0.8, {left:0, delay:3.7, ease:Power4.easeOut});
TweenMax.to(".dark", 0.6, {width:0, left:500, delay:4.2, ease:Power0.easeOut});
TweenMax.to(".dark", 0, {left:-500, width:500, delay:5, onComplete:complete, repeat:-1});
function complete() {
	TweenMax.to(".dark", 0.8, {left:0, delay:2, ease:Power4.easeOut});
	TweenMax.to(".dark", 0.8, {width:0, left:500, delay:2.5, ease:Power0.easeOut});
	TweenMax.to(".dark", 0, {left:-500, width:500, delay:4});
};

But doesn't seems to works, it only works withouth:

repeat:-1

at the end of the line, and repeat only once.

I'm sure I'm missing something...

Thanks a lot :)

See the Pen yNeLJW by uomopalese (@uomopalese) on CodePen

Share this post


Link to post
Share on other sites

You could shorten it up big time by tweening the red line and then putting the blue line tween on a timeline that repeats infinitely.

 

See the Pen RPrwJy by sgorneau (@sgorneau) on CodePen

  • Like 3

Share this post


Link to post
Share on other sites

No worries, so do I. And that's the fun part!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.