Jump to content
Search Community

Different ScrollTrigger end value depending on scroll direction

she codes test
Moderator Tag

Go to solution Solved by ZachSaucier,

Recommended Posts

Hi there,

 

I have a ScrollTrigger timeline with several steps, which is working as expected. I also have a fixed navigation menu that translates out of view when you scroll down, so the current end value of the timeline works great for the onLeave event.

But when I scroll back up, the menu translates back into view and covers the beginning of the onEnterBack event.

Is there a way to have different end value for this ScrollTrigger timeline depending on the direction of the scroll?

I would really appreciate any help or thoughts here.

 

See the Pen JjKeqRE by she_codes_ (@she_codes_) on CodePen

Link to comment
Share on other sites

Yes, thank you - I have now created a simple demo in Codepen and added it to the main question post (it's not my original timeline, but it illustrates the point).

 

When entering the viewport the content fades/slides in, and when leaving - it fades/slides out. This needs to happen in both directions. I have turned markers on, to illustrate how the menu is obscuring the end point on scrolling back. And one needs to scroll really fast in order to see the animation.

 

I understand different end point for each direction is not possible... Is there a way then to maybe update the end value onLeave, so there is a already a new value when I start scrolling down?

 

Any thoughts greatly appreciated.

 

Link to comment
Share on other sites

Basically, I needed the onLeave action and onEnterBack action to happen at different trigger positions.

 

Two ScrollTriggers will definitely do that.

 

I was just wondering if ScrollTrigger end value could be modified on the go (on events) and which approach was better.

 

Thank you both.

Link to comment
Share on other sites

4 hours ago, she codes said:

I was just wondering if ScrollTrigger end value could be modified on the go (on events) and which approach was better.

You could use a functional value and tell ScrollTrigger to refresh, so yes the end value can be modified. But from what it sounds like two ScrollTriggers would be easier. 

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