Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Muzammil hasan

slecting child elements

Recommended Posts

Welcome to the GreenSock forums @Muzammil hasan , you could do something like the following for instance.

 

var target = document.querySelectorAll(".main-content")[0];
gsap.from(target.children,
  {
    y: 100,
    ease: "Power2.easeInOut",
    opacity: 0,
    duration: 0.4,
    stagger: 0.3,
  }
);

Hopefully that helps your efforts.

  • Like 5
Link to post
Share on other sites

 

Or how about 

 

gsap.from(
  ".main-content > *",
  {
    y: 100,
    ease: "Power2.easeInOut",
    opacity: 0,
    duration: 0.4,
    stagger: 0.3,
  }
);

 

  • Like 5
Link to post
Share on other sites

What @akapowl suggested is good also if you want to target every instance that uses “.main-content”. Then you can instead just use the child combinator > and wildcard * like he has shown for an even cleaner approach. 😉

  • Like 4
Link to post
Share on other sites

Also note that ease: "Power2.easeInOut" is not a valid ease. It should probably be the condensed string form instead: ease: "power2.inOut".

  • Like 3
Link to post
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.

×