Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
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

Link to comment
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
Link to comment
Share on other sites

Thanks, I have a lot to learn...

:)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×