Jump to content
Search Community

How to check if the scrollTriggers is already end or start (console.log("start" or "end"))?

Xenex122 test
Moderator Tag

Recommended Posts

Basically what I'm trying to say is that. If the scrollTrigger hits the end of the animation it supposed to console.log("end") if its on the end trigger and if going back then it will be console.log("start")  if only it hits the start trigger
 

function CallBack(e) {
   console.log(e)
}

end: () => if(hasEnd) { Callback("End") } else if (hasStart) {Callback("start")} 

I don't have a codepen to make sample to it but it somehow related to my recently problem that I posted here.

but I think my question is here is far so I made a repost and try to simplify it.

Link to comment
Share on other sites

@akapowl I've created this new one but it doesn't work...I just based on your codes..but it doesn't make sense to me check this 

See the Pen BaYGaoK by myth-vince (@myth-vince) on CodePen



EDIT when I scroll it up until it reach the starter it doesnt change into scrollDown?? care to explain? but the code you give is working just only the starting point.

Link to comment
Share on other sites

That is because in your scenario things never actually get past that start point when scrolling back up - you could just set the end to something like 'top -1px' e.g. and it should work.

 

Also, be careful with your naming conventions - you store the element '.scroller' in a variable named scrollDown and then you also have an element with the class of .scrolldown in your HTML - which is very confusing. Just note, that I changed that variable name in the pen below.

 

See the Pen zYRMBqa by akapowl (@akapowl) on CodePen

 

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