一些支持触摸的浏览器(例如 Mobile Safari)在其对象上具有可用的scaleandrotation属性,event用于诸如touchmove.
我可以像这样检测对scale属性的支持......
document.body.addEventListener("touchmove", function(event) {
var supportsScaleProperty = !!event.scale;
});
但是,有没有一种方法可以检测到它而不必绑定监听器然后在回调中查找属性?
例如,如果这有效?
var supportsScaleProperty = !!(new CustomEvent("TouchEvents")).scale;
我试过看createEvent(),但它已被弃用。我查看了new CustomEvent(),但不确定要为触摸事件使用哪个字符串。