禁用双击"变焦"在触摸设备的浏览器选项 [英] Disable double-tap "zoom" option in browser on touch devices
本文介绍了禁用双击"变焦"在触摸设备的浏览器选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在指定的元素在浏览器(在触摸设备)停用在双击缩放功能 无禁用所有的缩放功能
I want to disable the double-tap zoom functionality on specified elements in the browser (on touch devices), without disabling all the zoom functionality.
例如:一个元素可事情发生可挖多次。这适用于桌面浏览器(如预期)的罚款,但在触摸设备的浏览器,它会放大。
For example: One element can be tapped multiple times for something to happen. This works fine on desktop browsers (as expected), but on touch device browsers, it will zoom in.
推荐答案
我只是想正确回答我的问题是有些人不看答案下面的评论。所以在这里,它是:
I just wanted to answer my question properly as some people do not read the comments below an answer. So here it is:
(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').trigger('click');
});
};
})(jQuery);
我不写这个,我只是修改了它。我发现iOS的唯一版本在这里: https://gist.github.com/2047491 (感谢Kablam)
这篇关于禁用双击"变焦"在触摸设备的浏览器选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文