Jump to content
Search Community

right way to organize ScrollTrigger with Timeline?

Jess.Park test
Moderator Tag

Recommended Posts

Hi. I need help with ScrollTrigger + Timeline. I'm totally lost : - (

 

I have several div.screens that each styles are set by screensData array.

What I want to do is below.

 

<when trigger is pinned by ScrollTrigger>

1. animate .bg backgroundColor from 'transparent' to 'black' 

2. wait for 0.2s

3. animate each .screens opacity from 0 to'screensData[i].opacity', scale from'screensData[i].scale-=0.2' to'screensData[i].scale'

 

<when trigger is unpinned by ScrollTrigger> - basically reverse the above

1. animate each .screens opacity from'screensData[i].opacity'to 0, scale from 'screensData[i].scale'to 'screensData[i].scale-=0.2'

2. wait for 0.2s

3. animate .bg backgroundColor from 'black' to 'transparent'

 

I thought it was going to be simple, but somehow it's not.

 

 

Main problems are,

A ) screens.forEach animation isn't firing at all. What am I doing wrong?

 

B ) I'm not sure how to convert 'stagger: 0.15 * dir'  in forEach function.

     (stagger in order when scrolled down, stagger in reversed order when scrolled up)

 

C ) Is there a better way to do this with less lines?

      something like <when trigger is pinned, play timelineA / when unpinned, play timelineA.reverse(0)>

 

 

 

See the Pen jOVvXxp by impetusjj (@impetusjj) on CodePen

Link to comment
Share on other sites

Hey Jess. You're making some of the most common GSAP mistakes so I recommend fixing those.

 

Your setup is a bit confusing to me though. If all that you're doing is playing or reversing an animation why do you need to create a new animation each time? One of the tips about animating efficiently (another great article to read) is to use control methods to control animations.

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