Jump to content
Search Community

pointerup fired for draggable's onclick in mobile view

seansly test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

loading the codepen and then turning on the mobile view, refresh the page, then click and you should get two events.  I don't think this is intended but maybe I just have it set up wrong.  It doesn't happen outside of mobile view.

 

console:

image.png.e01827a9a3eff2e4b483638cc2b2b449.png

 

It seems like the double event happens on a phone or when the browsers mobile mode is set to a phone size specifically, responsive wont trigger two events

 

Any advice?

 

See the Pen jOwvmNy by seansly (@seansly) on CodePen

Link to comment
Share on other sites

If I clear out some of your other callbacks and just leave the onClick, it only fires once (as it should) - are you seeing that same behavior? It looks to me like you've got something contaminating things, like why are you calling .enable().update() in the onPress? 

 

After experimenting for a short time, it stopped breaking - I'm not sure if you changed something in the code when I refreshed or what. But I couldn't get it to break after initially noticing the extra callbacks causing the issue (even when I re-enabled them). 

Link to comment
Share on other sites

I still get the issue with onClick as the only callback.  It seems to not "break" as often on codepen, but when I run this locally it breaks every time.  If you refresh the page after loading a mobile view, it should break on codepen though.

 

Quote

like why are you calling .enable().update() in the onPress?

I started building this off an old gsap example and from what I can tell, since I technically need to adjust the viewbox window instead of actually dragging something around... the draggable is attached to a proxy element that gives me pointer information and it doesn't work correctly unless I have that .enable().update() in the onPress.  If that's removed you should notice the viewbox jumping around.

 

the gsap reference is here:

See the Pen bGRLpwZ by seansly (@seansly) on CodePen

Link to comment
Share on other sites

  • Solution

I think I figured out the scenario that was causing the issue for you. It's a long story but we had to put a ton of work into normalizing behavior across all the browsers because they all have different quirks, bugs, and funky behavior and one of those workarounds involved checking to see if a click recently happened. The threshold was 39ms but I was able to measure it at 40 or 44 at times, and that's when it allowed the other one through (it's a synthetic one that works around Firefox/Safari quirks). I just increased that threshold to 99ms and it seems to be working perfectly now. Here's an updated file: https://assets.codepen.io/16327/Draggable3.min.js

 

Better? 

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