Jump to content
Search Community

Scrolltrigger end n pixels after the bottom of the element

XXVII test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Hello,

I'm trying to start the trigger 100px before the top of element reaches the center of the viewport and stop the trigger 100px after the bottom of the element reaches the center of the viewport.

 

I succeded at starting 100px before, but I can't figure out how to end 100px after, this is the first thing I tried:

 

scrollTrigger: {
  start:        '-100px center',
  end:          '+100px center',
  trigger:      element,
  toggleClass:  'class'
}

Other attempts:

"bottom +100px center"

"100% +100px center"

"+=100px center"

Any suggestion?
Thank you

Link to comment
Share on other sites

  • Solution

Hi @XXVII welcome to the forum! Be sure to include a minimal demo next time, so that we can see the code not working in action.

 

start: 'top-=100px center',
end: 'bottom+=100px center',

You almost had it. You want it to be relative to the bottom of the element so you can use `-=` or `+=`, so the end: trigger would be `end: 'bottom+=100px center'` and GSAP is smart, but even though `-100px` works I would suggest writing it out like so `start: 'top-=100px center'`, this way your code will be easier to read.

  • Like 1
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...