Thank you for the suggestion, I tried and was able to make it work.
Below code is what I ended up (for some one who is interested in it)
(function () {
function _duckPunchTouchHandler(event) {
// ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
return;
}
var touch = event.originalEvent.changedTouches[0];
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent({
touchstart: "mousedown",
touchmove: "mousemove",
touchend: "mouseup"}[event.type],
true, true, window, 1,
touch.screenX, touch.screenY,
touch.clientX, touch.clientY, false,
false, false, false, 0, null);
touch.target.dispatchEvent(simulatedEvent);
};
DuckPunchWicketDrag = {
init : function () {
var init_org = Wicket.Drag.init;
var mousedown_org = Wicket.Drag.mouseDownHandler;
var clean_org = Wicket.Drag.clean;
var mousemove_org = Wicket.Drag.mousemove;
var mouseup_org = Wicket.Drag.mouseUp;
var mouseout_org = Wicket.Drag.mouseOut;
Wicket.Drag.init = function(element, onDragBegin, onDragEnd,
onDrag) {
Wicket.Event.add(element, "touchstart",
_duckPunchTouchHandler);
init_org.call(this, element, onDragBegin, onDragEnd,
onDrag);
};
Wicket.Drag.mouseDownHandler = function (e) {
$(document).on('touchmove', _duckPunchTouchHandler);
$(document).on('touchend', _duckPunchTouchHandler);
return mousedown_org.call(this, e);
};
Wicket.Drag.clean = function (element) {
Wicket.Event.remove(element, "touchstart",
_duckPunchTouchHandler);
clean_org.call(this, element);
};
Wicket.Drag.mousemove = function (e) {
return mousemove_org.call(this, e);
};
Wicket.Drag.mouseUp = function (e) {
if (Wicket.Drag.current) {
$(document).off('touchmove', _duckPunchTouchHandler);
$(document).off('touchend', _duckPunchTouchHandler);
}
mouseup_org.call(this, e);
};
Wicket.Drag.mouseOut = function (e) {
mouseout_org.call(this, e);
};
}
};
})();
Regards,
Rakesh.A
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]