Skip to content

Commit 567c732

Browse files
committed
fixed greedy capture on items with handles (afaik)
1 parent 4754680 commit 567c732

1 file changed

Lines changed: 30 additions & 18 deletions

File tree

jquery.ui.touch-punch.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery UI Touch Punch 0.2.0
2+
* jQuery UI Touch Punch 0.2.1
33
*
44
* Copyright 2011, Dave Furfero
55
* Dual licensed under the MIT or GPL Version 2 licenses.
@@ -41,21 +41,21 @@
4141

4242
// Initialize the simulated mouse event using the touch event's coordinates
4343
simulatedEvent.initMouseEvent(
44-
simulatedType, // type
45-
true, // bubbles
46-
true, // cancelable
47-
window, // view
48-
1, // detail
49-
touch.screenX, // screenX
50-
touch.screenY, // screenY
51-
touch.clientX, // clientX
52-
touch.clientY, // clientY
53-
false, // ctrlKey
54-
false, // altKey
55-
false, // shiftKey
56-
false, // metaKey
57-
0, // button
58-
null // relatedTarget
44+
simulatedType, // type
45+
true, // bubbles
46+
true, // cancelable
47+
window, // view
48+
1, // detail
49+
touch.screenX, // screenX
50+
touch.screenY, // screenY
51+
touch.clientX, // clientX
52+
touch.clientY, // clientY
53+
false, // ctrlKey
54+
false, // altKey
55+
false, // shiftKey
56+
false, // metaKey
57+
0, // button
58+
null // relatedTarget
5959
);
6060

6161
// Dispatch the simulated event to the target element
@@ -68,16 +68,18 @@
6868
*/
6969
mouseProto._touchStart = function (event) {
7070

71+
var self = this;
72+
7173
// Ignore the event if another widget is already being handled
72-
if (touchHandled) {
74+
if (touchHandled || !self._mouseCapture(event)) {
7375
return;
7476
}
7577

7678
// Set the flag to prevent other widgets from inheriting the touch event
7779
touchHandled = true;
7880

7981
// Track movement to determine if interaction was a click
80-
this._touchMoved = false;
82+
self._touchMoved = false;
8183

8284
// Simulate the mouseover event
8385
simulateMouseEvent(event, 'mouseover');
@@ -95,6 +97,11 @@
9597
*/
9698
mouseProto._touchMove = function (event) {
9799

100+
// Ignore event if not handled
101+
if (!touchHandled) {
102+
return;
103+
}
104+
98105
// Interaction was not a click
99106
this._touchMoved = true;
100107

@@ -108,6 +115,11 @@
108115
*/
109116
mouseProto._touchEnd = function (event) {
110117

118+
// Ignore event if not handled
119+
if (!touchHandled) {
120+
return;
121+
}
122+
111123
// Simulate the mouseup event
112124
simulateMouseEvent(event, 'mouseup');
113125

0 commit comments

Comments
 (0)