default-passive-events
Version:
Makes {passive: true} by default when EventListenerOptions are supported
3 lines (2 loc) • 1.19 kB
JavaScript
var e,t=["scroll","wheel","touchstart","touchmove","touchenter","touchend","touchleave","mouseout","mouseleave","mouseup","mousedown","mousemove","mouseenter","mousewheel","mouseover","pointermove","pointerenter","pointerleave","pointerdown","pointerup","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel"];if(function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e}()){var n=EventTarget.prototype.addEventListener;e=n,EventTarget.prototype.addEventListener=function(n,o,i){var r,s="object"==typeof i&&null!==i,a=s?i.capture:i;(i=s?function(e){var t=Object.getOwnPropertyDescriptor(e,"passive");return t&&!0!==t.writable&&void 0===t.set?Object.assign({},e):e}(i):{}).passive=void 0!==(r=i.passive)?r:-1!==("undefined"!=typeof window&&window.defaultPassiveEvents_supportedPassiveEvents?window.defaultPassiveEvents_supportedPassiveEvents:t).indexOf(n)&&!0,i.capture=void 0!==a&&a,e.call(this,n,o,i)},EventTarget.prototype.addEventListener._original=e}
//# sourceMappingURL=index.js.map