Jump to content
Search Community

.play() not activating TweenMax.staggerFrom

Will Chase 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 all, I'm new to GSAP (and to JS), so forgive me if I'm just making a stupid mistake. 

 

I'm using the GSAP advanced staggers to animate a waffle chart grid (). I've got the tween set up using TweenMax.staggerFrom, but then I can't seem to get any of the methods like .isActive(), .play(), .reverse(), etc. to work. I've set up a little button to activate them but nothing happens. Searched and tested stuff for hours but I can't seem to figure out what I'm doing wrong. 

 

Thanks!

See the Pen arGoxw by will-r-chase (@will-r-chase) on CodePen

Link to comment
Share on other sites

Welcome the forums (and GSAP)! 

 

The problem is just that TweenMax.staggerFrom() returns an ARRAY of tweens....and you're trying to call play() on an array instead of on an animation instance. If your goal is to control a group of tweens, you should definitely be using a TimelineLite or TimelineMax. Those have their own staggerFrom() method that does exactly the same thing as TweenMax.staggerFrom(), but puts all the resulting tweens into a timeline wrapper that you can then control very easily. Here's a forked demo: 

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

 

I'd also strongly recommend reading this article: https://css-tricks.com/writing-smarter-animation-code/

 

Happy tweening!

  • Like 1
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...