|
1 | 1 | /*! |
2 | | - * jQuery UI Touch Punch 0.2.0 |
| 2 | + * jQuery UI Touch Punch 0.2.1 |
3 | 3 | * |
4 | 4 | * Copyright 2011, Dave Furfero |
5 | 5 | * Dual licensed under the MIT or GPL Version 2 licenses. |
|
41 | 41 |
|
42 | 42 | // Initialize the simulated mouse event using the touch event's coordinates |
43 | 43 | 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 |
59 | 59 | ); |
60 | 60 |
|
61 | 61 | // Dispatch the simulated event to the target element |
|
68 | 68 | */ |
69 | 69 | mouseProto._touchStart = function (event) { |
70 | 70 |
|
| 71 | + var self = this; |
| 72 | + |
71 | 73 | // Ignore the event if another widget is already being handled |
72 | | - if (touchHandled) { |
| 74 | + if (touchHandled || !self._mouseCapture(event)) { |
73 | 75 | return; |
74 | 76 | } |
75 | 77 |
|
76 | 78 | // Set the flag to prevent other widgets from inheriting the touch event |
77 | 79 | touchHandled = true; |
78 | 80 |
|
79 | 81 | // Track movement to determine if interaction was a click |
80 | | - this._touchMoved = false; |
| 82 | + self._touchMoved = false; |
81 | 83 |
|
82 | 84 | // Simulate the mouseover event |
83 | 85 | simulateMouseEvent(event, 'mouseover'); |
|
95 | 97 | */ |
96 | 98 | mouseProto._touchMove = function (event) { |
97 | 99 |
|
| 100 | + // Ignore event if not handled |
| 101 | + if (!touchHandled) { |
| 102 | + return; |
| 103 | + } |
| 104 | + |
98 | 105 | // Interaction was not a click |
99 | 106 | this._touchMoved = true; |
100 | 107 |
|
|
108 | 115 | */ |
109 | 116 | mouseProto._touchEnd = function (event) { |
110 | 117 |
|
| 118 | + // Ignore event if not handled |
| 119 | + if (!touchHandled) { |
| 120 | + return; |
| 121 | + } |
| 122 | + |
111 | 123 | // Simulate the mouseup event |
112 | 124 | simulateMouseEvent(event, 'mouseup'); |
113 | 125 |
|
|
0 commit comments