Jump to content


Repeat a little function onComplete.

Go to solution Solved by Shaun Gorneau,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

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:


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

  • Solution

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

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.