Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Mouse: Fix for binding touch events to mouse events (like UI Touch Punch) with Draggable #735

Closed
wants to merge 1 commit into from

5 participants

@pcvandam

Using any touch to mouse extension, like UI Touch Punch, will create empty ghost events in Draggable. Patch checks for these and cancels.

@pcvandam pcvandam Update ui/jquery.ui.mouse.js
Using any touch to mouse extension, like UI Touch Punch, will create empty ghost events in Draggable. Patch checks for these and cancels.
a3771da
@scottgonzalez

Why does it generate ghost events and why is it our responsibility to fix their erroneous events?

@pcvandam

I'm not sure. It isn't their bug, it is the mouse handler (or draggable) that is creating these events. Or perhaps it is an Safari iPad bug.

It cannot be fixed on the level of the extension it seems, but this simple fix cures it for all touch conversion-related extensions.

Do you want an extended test case?

@scottgonzalez

@furf do you know what's going on here?

@scottgonzalez

@pcvandam You're saying that jQuery UI is generating additional events? If so, can you point to where that generation is occurring?

@furf

@pcvandam which ghost events are you seeing?

can you provide an extended use case? feel free to use this fiddle as a starting point: http://jsfiddle.net/bmL4L/3/

@pcvandam

Sorry for the delay.

Eventually I found the unlikely culprit: cursor: 'move' in Draggable. Setting this directive causes the iPad Safari with Touch Punch to create the extra empty mouse-events.

http://jsbin.com/eqodow/1

You can easily test with the iPad simulator and see the 'flash' where it tries to move to the faulty location. Removing cursor: 'move' fixes this issue. Or you can filter the erroneous events from ui.mouse as in my commit, but that might not be the best fix as I look at it now.

@jzaefferer
Owner

@furf @pcvandam so is this something touchpunch can address? Otherwise we should just land this for 1.9.1. The interaction redesign will invalidate the whole context eventually.

@mikesherov
Collaborator

any progress here @pcvandam, @furf, @jzaefferer ?

@mikesherov
Collaborator

Thanks for this patch! I'm not so sure see why we should be fixing this, though. I'm going to close this pull request, and will reopen it if we here back from @furf saying there is no reasonable way to fix this in touchpunch. Thanks again everyone.

@mikesherov mikesherov closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 3, 2012
  1. @pcvandam

    Update ui/jquery.ui.mouse.js

    pcvandam authored
    Using any touch to mouse extension, like UI Touch Punch, will create empty ghost events in Draggable. Patch checks for these and cancels.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  ui/jquery.ui.mouse.js
View
3  ui/jquery.ui.mouse.js
@@ -114,6 +114,9 @@ $.widget("ui.mouse", {
if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
return this._mouseUp(event);
}
+
+ // Prevent ghost event
+ if (event.which === 0) return;
if (this._mouseStarted) {
this._mouseDrag(event);
Something went wrong with that request. Please try again.