Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions jquery.ui.touch-punch.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,32 @@
return;
}

if ($(event.target).is("input") || $(event.target).is("textarea") || $(event.target).is("button")) {
return;
}

event.preventDefault();

var touch = event.originalEvent.changedTouches[0],
simulatedEvent = document.createEvent('MouseEvents');

// Initialize the simulated mouse event using the touch event's coordinates
simulatedEvent.initMouseEvent(
simulatedType, // type
true, // bubbles
true, // cancelable
window, // view
1, // detail
touch.screenX, // screenX
touch.screenY, // screenY
touch.clientX, // clientX
touch.clientY, // clientY
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
0, // button
null // relatedTarget
true, // bubbles
true, // cancelable
window, // view
1, // detail
touch.screenX, // screenX
touch.screenY, // screenY
touch.clientX, // clientX
touch.clientY, // clientY
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
0, // button
null // relatedTarget
);

// Dispatch the simulated event to the target element
Expand Down Expand Up @@ -145,7 +149,7 @@
* original mouse event handling methods.
*/
mouseProto._mouseInit = function () {

var self = this;

// Delegate the touch handlers to the widget's element
Expand All @@ -163,7 +167,7 @@
* Remove the touch event handlers
*/
mouseProto._mouseDestroy = function () {

var self = this;

// Delegate the touch handlers to the widget's element
Expand All @@ -177,4 +181,4 @@
_mouseDestroy.call(self);
};

})(jQuery);
})(jQuery);