Jump to content
Search Community

stagger tweening

nicodev test
Moderator Tag

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 think I miss something. I am trying so make a simple stagger animation of speech bubbles with staggerTo. Just would like the each item to disapear before another comes. Is there a way to add a callback function or something else to do this ? See my pen. Thanks for helping. 

 

var $temoignage = $('.temoignage'),
tlTemoignages;

tlTemoignages = new TimelineMax({ 
  repeat: -1,
  repeatDelay: 1 }); 

tlTemoignages 
  .staggerTo($temoignageTexte, 2, {autoAlpha: 1, x: 100, ease:Power3.easeOut}, 1);

 

See the Pen BKgVPV by ndevaux (@ndevaux) on CodePen

Link to comment
Share on other sites

Yes, there is.

 

See the Pen aNgKgm?editors=0010 by dipscom (@dipscom) on CodePen

 

 

Check out the docs for any of the stagger methods. Scroll down a bit and you will see a detailed explanation on how they work. There is one example that is exactly what you are asking about.

 

http://greensock.com/docs/#/HTML5/GSAP/TweenMax/staggerTo/

 

 

Just watch out for the gotcha. Even though you can pass "{self}" as a parameter, for some reason, I had to add ".target" to the element being passed, otherwise it would not Tween. I do not know why that is but I can see the logic behind it. As I guess the "{self}" parameter is referring to the actual DOM node... Hopefully Jack will swing by and give us an explanation as to why that is the case.

  • Like 2
Link to comment
Share on other sites

Yep, {self} would be a reference to the tween instance itself (not the target). That's why you had to add ".target" to it, to reference the tween's target (the DOM node in this case)

 

Another way you could do this is with another staggerTo() call instead of callbacks. You just delay those tweens a bit so that they line up where you want. This way, all the animation is inside a single timeline instance that you can easily seek(), reverse(), timeScale() or anything like that:

http://codepen.io/anon/pen/aNgRWz?editors=0010

 

Notice I created some variables at the top that you can play with for the timing of all the staggers, durations, etc. 

 

Happy tweening!

  • Like 4
Link to comment
Share on other sites

  • 1 year later...

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...