I\'m creating a site on Safari for iPad. I need to prevent the zoom on double-tapping event but I have two problems:
try this modified code. It should work for both android and IOS devices
(function($) {
$.fn.nodoubletapzoom = function() {
$(this).bind('touchstart', function preventZoom(e){
var t2 = e.timeStamp;
var t1 = $(this).data('lastTouch') || t2;
var dt = t2 - t1;
var fingers = e.originalEvent.touches.length;
$(this).data('lastTouch', t2);
if (!dt || dt > 500 || fingers > 1){
return; // not double-tap
}
e.preventDefault(); // double tap - prevent the zoom
// also synthesize click events we just swallowed up
$(e.target).trigger('click');
});
};
})(jQuery);
Then apply the nodoubletapzoom() to the body tag
$("body").nodoubletapzoom();
Mobile Safari does not support the javascript ondblclick event. It's interpreted by Safari as a "zoom".
Raul Sanchez has posted a potential solution: http://appcropolis.com/implementing-doubletap-on-iphones-and-ipads/