Jump to content
GreenSock

TomS0

ScrollTrigger onEnter only fires when scrolling down

Recommended Posts

Hey everyone,

 

onEnter only seems to fire when scrolling down, not strictly when it has entered the viewport (based on the start, end params) as you would expect. I have used onUpdate to get around this but for performance reasons I would like to avoid it. 

 

Do you have any ideas what I'm doing wrong here?

 

Thanks,

Tom

See the Pen ZExzMXz by TheTomS (@TheTomS) on CodePen

Link to comment
Share on other sites

You need to use onEnterBack: () => {} if you want to do something when you enter backwards. You might also be able to use onToggle but I haven't tried that before.

  • Like 1
Link to comment
Share on other sites

Perhaps you're looking for this?: 

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

 

Steve is correct - onEnter is for when it enters as scroll increases. onEnterBack is for the opposite way. You can use onToggle and isActive to simplify things too, like in the demo:

onToggle: self => self.trigger.innerText = self.isActive ? "In View" : "Not In View"

 

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