Jump to content
Search Community

Limit Observer to pointer

Thomas Günther
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Thomas Günther
Posted

Heya ?

 

I noticed I can not limit an Observer to type: pointer. It will always trigger, also on mobile/touch devices.

 

While I can use a condition like e.event.type.includes('pointer') I'm wondering if this is a bug.

 

In this codepen I listen to onLeft and onRight but I don't want this on mobile devices. It will scroll, jump back and then animate the scroll.

See the Pen qBxMVmB by medienbaecker (@medienbaecker) on CodePen.

  • Solution
Posted

Great catch, @Thomas Günther. Sorry about the confusion there. That's fixed in the next release, but for now it should be as simple as wrapping your .observe() in this:

if (ScrollTrigger.isTouch !== 1) { // <- skip if it's a touch-only device
  ScrollTrigger.observe({
    type: "pointer",
    ...
  });
}

 

 

 

  • Like 1
Thomas Günther
Posted

Thanks for the quick answer, @GreenSock! I'm glad you could fix it ?

 

In the meantime the isTouch is also a much better solution than my event type condition, thanks!

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