Jump to content
GreenSock

shMattyP93

ScrollTrigger Start Before Section

Recommended Posts

Is there any way to make a scrollTrigger event start earlier than defined? Currently, I have my event starting at the "top" of the section, is there any way to add say 150px to that so it starts slightly before the user actually scrolls to the start position?

Link to comment
Share on other sites

Hi,

 

All you have to do is play with the start position. Keep in mind that the start and end parameters signal the position of a specific part of the trigger element, relative to the scroller area. If you want to start something before becomes visible you need to signal that the top of the element hits the bottom of the scroller, plus a few pixels or percentage.

 

gsap.to("#box", {
  xPercent: 150,
  scrollTrigger: {
    trigger: "#two",
    start: "top bottom+=150px",
    end: "top center",
    scrub: true,
  }
});

In this example the green and purple boxes should be perfectly aligned, but the animation of the purple box starts before it enters the viewport:

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

 

You can read about it in the docs:

https://greensock.com/docs/v3/Plugins/ScrollTrigger

 

I hope this makes things clearer.

 

Happy Tweening!

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