Jump to content
Search Community

Staggering Elements under a div

webfeak7 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

Hey I have a website which generates posts and I was wondering if I could use the stagger animation to Tween them from opacity 0 to opacity 1 on page load. The amount of elements differs since the website is dynamic. It is structured as follows.

<div id="message-container">

<div class="message1">

<div class="message2">

<div class="message3">


I want to animate the divs with class .message<insert number>. Is there a way to do this by targeting the child elements of the message container and then doing the stagger effect on that?

Link to comment
Share on other sites

Yeah its possible. 
The best thing is if the children div's will have a unique class name. In your case each div has a diffrent class name (message1,message2..), best thing is to give them a common class name, and then staggering them.
But if you know that all of the child elements are messages you can easily do something like this:


here's a codepen:

See the Pen avits by bazooki (@bazooki) on CodePen


Hope this helps =)

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