@yued/fastclick
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -128,7 +128,24 @@ ;(function () { | ||
var passiveListener = (function checkPassiveListener() { | ||
//判断浏览器是否支持 {passive: true} | ||
var supportsPassive = false; | ||
try { | ||
var opts = Object.defineProperty({}, 'passive', { | ||
get: function () { | ||
supportsPassive = true; | ||
} | ||
}); | ||
window.addEventListener('testPassiveListener', null, opts); | ||
} catch (e) { | ||
supportsPassive = false; | ||
} | ||
return supportsPassive; | ||
}()); | ||
var listenerOptions = passiveListener ? { passive: false } : false; | ||
layer.addEventListener('click', this.onClick, true); | ||
layer.addEventListener('touchstart', this.onTouchStart, false); | ||
layer.addEventListener('touchmove', this.onTouchMove, false); | ||
layer.addEventListener('touchend', this.onTouchEnd, false); | ||
layer.addEventListener('touchcancel', this.onTouchCancel, false); | ||
layer.addEventListener('touchstart', this.onTouchStart, listenerOptions); | ||
layer.addEventListener('touchmove', this.onTouchMove, listenerOptions); | ||
layer.addEventListener('touchend', this.onTouchEnd, listenerOptions); | ||
layer.addEventListener('touchcancel', this.onTouchCancel, listenerOptions); | ||
@@ -135,0 +152,0 @@ // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) |
{ | ||
"name": "@yued/fastclick", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Polyfill to remove click delays on browsers with touch UIs.", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
Sorry, the diff of this file is not supported yet
48389
727