waves/public/assets/g/commodoreclicker/js/thirdparty/jquery.nodoubletapzoom.js
2025-04-09 17:11:14 -05:00

22 lines
712 B
JavaScript

/*
Prevent double-tap to zoom on touch-capable devices
John Sundstrom, adapted by Wouter Konecny
http://stackoverflow.com/questions/10614481
*/
(function($) {
$.fn.nodoubletapzoom = function() {
$(this).bind('touchstart', function preventZoom(e) {
var t2 = e.timeStamp
, t1 = $(this).data('lastTouch') || t2
, dt = t2 - t1
, 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
$(this).trigger('click');
});
};
})(jQuery);