Jump to content


ScrollTrigger with Locomotive scroll - this keyword

Go to solution Solved by OSUblake,

Recommended Posts


I just forked the ScrollTrigger with locomotive scroll codepen example and made some small changes to the javascript code. Basically, I put the code in a class and instead of defining a const locoScroll, I used the this keyword and this.locoScroll. With the class definition and original const declaration, everything works fine, but the code breaks when I use this.locoScroll instead.  I realize this might not be related to ScrollTrigger, but since the error is happening inside the ScrollTrigger.scrollerProxy callback, I'd thought I could ask here.


Thanks for any help in advance.

See the Pen rNzdByY?editors=0011 by Akbarbakhshi (@Akbarbakhshi) on CodePen

Link to comment
Share on other sites

  • Solution

You would need to use arrow functions as they aren't scoped...


scrollTop: (value) => {
  return arguments.length ? this.locoScroll.scrollTo(value, 0, 0) : this.locoScroll.scroll.instance.scroll.y;


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