Jump to content
Search Community

Loop img after fade in

GO4ITJB test
Moderator Tag

Recommended Posts

Hi, First time posting so obviously BIG time noob :)

 

I have this timeline and I am wondering after the cans fade in on the screen, how would you make them loop over and over after they all go through on cycle.

Right now they stop after the cycle finishes. I tried with the repeat -1 but then the fade in on screen happens again and I don't want that part only where the cans keep cycling through over and over and over and over and over and over *inhales big chunk of air* and over and over and over......

 

I am using TimelineMax and TweenMax

 

Thanks :) 

 

 

tl.fromTo(cans, 0.7, {x: '300%'}, {x: '-50%'})
.fromTo(cans[0], 1, {opacity: 1}, {opacity: 1})
.fromTo(cans[1], 1, {opacity: 0}, {opacity: 1})
.fromTo(cans[2], 1, {opacity: 0}, {opacity: 1})

See the Pen jOrXZoO by go4itjb (@go4itjb) on CodePen

Link to comment
Share on other sites

Hi @GO4ITJB

First, it's difficult to debug this without a working example. Can you set up a CodePen so that we can help trouble shoot?


Also, I'd highly recommend using the new GSAP3 Syntax (not TimelineMax/TweenMax).

You can repeat individual tweens as well, so you could add repeat: -1 in your fromTo animations, but you'd just need to set a global time marker to set the start time on each of them, otherwise, you wouldn't get past the first one: ... .fromTo(cans[1], { opacity: 0 }, { opacity: 1, duration: 1, repeat: -1 }, 1} OR just run all of them as a single stagger animation ... .fromTo(cans, { autoAlpha: 0 }, { autoAlpha: 1, duration: 1, stagger: 1, repeat: -1 })

Link to comment
Share on other sites

Hey GO4ITJB and welcome to the GreenSock forums.

 

If you're just learning, there's zero reason why you should use the old version of GSAP. GSAP 3 has a smaller file size, a sleeker API, and a bunch of new features. We highly recommend getting started here:

 

As for your question, using a repeat of -1 is the way to go. You should probably separate the intro animation from the looping animation. You should also make sure the kill off the tweens that are running when the page transitions. And make sure the layering and fading in is correct. Here's one way of setting it up:

See the Pen eYzbMRR?editors=0010 by GreenSock (@GreenSock) on CodePen

 

I highly recommend that you also read my article about animating efficiently and the most common GSAP mistakes :) 

 

Be sure to use the "fork" button on CodePen for making new versions of your project so that the context is kept for these forums.

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.
×
×
  • Create New...