Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
BurntMatch

staggerFrom only animating first image in sequence

Go to solution Solved by Carl,

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

G'day.

 

My apologies if I haven't done this correctly. Literally my first time on here and presenting a pen.

 

So my issue is this...I am building my webpage, and the portfolio page opens with the navigation bar at the top and social media bar at the bottom (irrelevant for this demo because these animations work), tweening from opacity 0, then my 14 portfolio buttons staggering in from left one by one to array in a 3 x 5 formation:

 

var $Nav = $('Nav'),

$socialmedia = $('socialmedia'),
$imggal = $('imggal'),
tl = new TimelineMax();
 
tl
.from("#Nav", 2, {opacity:0})
.from("#socialmedia", 2, {opacity:0}, 0.5)
.staggerFrom("#imggal", 0.5, {x:-2000, ease:Power1.easeOut}, 0.2);
 
)};
 
However, when I test this timeline, only the top left, or first img, actually animates. The rest are sitting there proudly visible, lazily doing nothing at all. It kind of says that the tween is working, but why the other 13 img boxes aren't is lost on me.
 
I hope this makes sense. Happy to give more details if necessary.
 
Cheers,
 
Adam.

post-46658-0-35841000-1473378516_thumb.png

post-46658-0-42333700-1473378676_thumb.png

See the Pen rrVgPo by BurntMatch (@BurntMatch) on CodePen

Link to comment
Share on other sites

  • Solution

Hi and welcome to the forums.

 

 

Thanks for the simplified demo.

 

The problem here is that IDs are supposed to be unique and applied to only ONE element. You have the id of #imggal on every image and this is bad.

You should switch to a class. Or you can just select every img in your gallery using "#gallery img"

TweenMax.staggerFrom("#gallery img", 0.5, {x:-2000, ease:Power1.easeOut}, 0.2);

http://codepen.io/GreenSock/pen/xEGovL?editors=1010

 

I noticed your demo wasn't loading TweenMax, you need to go to the JS tab settings (little gear icon) and add it

 

e1a2cca0bed344a990a03b00fdd024da.png

  • Like 1
Link to comment
Share on other sites

Carl = Superhero.

 

Thanks heaps for that Carl. Really very appreciative. That was a bit of a brain fart on my behalf. Like I said, new to the game. But should've been on top of that. I swapped everything over from Class to ID and it works a treat now.

 

Cheers,

Adam.

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.

×