Jump to content
Search Community

Double animation does not work in ScrollTrigger

Umberto test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Thanks for the reply.

I tried this but it doesn't work, the animation doesn't start:

 

const boxes = gsap.utils.toArray('.maskDown span');
boxes.forEach(maskDown => {
  gsap.from(maskDown, { 
    scrollTrigger: {
      trigger: maskDown,
	  duration: 1.5, 
      y: 250, autoAlpha: 0, 
      skewY: 6, 
      ease:"power4.out",
	  stagger: { amount: 1.3}
    }
  })
});


Where am I wrong?

 

 

Link to comment
Share on other sites

You're putting the tween vars inside of the ScrollTrigger object. That's not good. Include them in the tween vars instead and it works:

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

 

Sides notes:

  • Good code formatting will help you and others code faster and catch your errors more easily.
  • You should try to use semantic HTML such as actual heading instead of a div with a heading class.
  • The .out is not necessary on your ease(s) because .out is the default.
  • Like 2
Link to comment
Share on other sites

 

 

Perfect.
Thank you for the advice.

I have more questions on how to write the code correctly:

 

1. Is it possible to insert a double class in the code?

const containers = gsap.utils.toArray('.heading-title-1, .heading-title-2');......

2. The same thing can also be done with ScrollTrigger.defaults ({.....}) ;?

ScrollTrigger.defaults ({ scroller: "#js-scroll", trigger: ".animation1, .animation2, animation3, ...." });

 

Thanks

Link to comment
Share on other sites

4 minutes ago, Umberto said:

Is it possible to insert a double class in the code?

Did you try it out? ;) 

 

4 minutes ago, Umberto said:

trigger: ".animation1, .animation2, animation3, ...."

A trigger like this doesn't make much sense. A trigger needs to be a singular element. You can't have a ScrollTrigger with multiple triggers.

 

I encourage you to go through the ScrollTrigger documentation and video again.

  • Like 1
Link to comment
Share on other sites

3 minutes ago, ZachSaucier said:

Did you try it out?

Of course, it works well, I just don't know if it's okay to use it

 

5 minutes ago, ZachSaucier said:

A trigger like this doesn't make much sense. A trigger needs to be a singular element. You can't have a ScrollTrigger with multiple triggers.

This I had doubts that it was a good solution, it was just a curiosity.

Link to comment
Share on other sites

  • 2 weeks later...

 

Hi, the help you gave me was important. 

I wanted to ask you if it was possible to animate multiple lines with the <span> without repeating the .heading-title-1 class. 

 

<div class="heading-tile-1">
    <div class="maskDown">
      <span>We create Digital</span>
    </div>
  </div>

  <div class="heading-tile-1">
    <div class="maskDown">
      <span> Branding </span>
    </div>
  </div>
......

 

Per capire meglio, volevo fare questo lavoro:

 

<div class="heading-tile-1">
    <div class="maskDown">
      <span>We create Digital</span>
     <span>Branding</span>
   <span>Experience</span>
    </div>
  </div>

 

is it possible?

 

Thanks

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