Jump to content
Search Community

Trying to animate Elements in view at the same time with scrolltrigger

altermajor test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

  • Solution

Hi @altermajor and welcome to the GreenSock forums!

 

In theses cases stagger is your best friend! ;) With stagger you can create a single GSAP instance controlled by ScrollTrigger and give each card a stagger equal or a bit bigger (maybe a few milliseconds) than the duration of the tween:

const cards = gsap.utils.toArray(".card");

cards.reverse();

gsap.to(cards, {
  y: -900,
  rotate: -90,
  duration: 0.5,
  stagger: 0.5,
  scrollTrigger: {
    trigger: ".section-two",
    start: "top top",
    end: "+=250%",
    markers: true,
    pin: true,
    scrub: true
  }
});

Here is a fork of your codepen:

See the Pen GRYmeOY by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

23 hours ago, Rodrigo said:

Hi @altermajor and welcome to the GreenSock forums!

 

In theses cases stagger is your best friend! ;) With stagger you can create a single GSAP instance controlled by ScrollTrigger and give each card a stagger equal or a bit bigger (maybe a few milliseconds) than the duration of the tween:

const cards = gsap.utils.toArray(".card");

cards.reverse();

gsap.to(cards, {
  y: -900,
  rotate: -90,
  duration: 0.5,
  stagger: 0.5,
  scrollTrigger: {
    trigger: ".section-two",
    start: "top top",
    end: "+=250%",
    markers: true,
    pin: true,
    scrub: true
  }
});

Here is a fork of your codepen:

 

 

 

Hopefully this helps.

Happy Tweening!

It works thanks! I also figured out an alternative solution as well!

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