Use passive option to avoid Chrome warning

This commit is contained in:
Andreas Hocevar
2019-11-13 10:08:20 +01:00
parent 6fe5c88614
commit fab8a449c3
2 changed files with 23 additions and 2 deletions

View File

@@ -44,3 +44,23 @@ export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
* @type {boolean}
*/
export const IMAGE_DECODE = typeof Image !== 'undefined' && Image.prototype.decode;
/**
* @type {boolean}
*/
export const PASSIVE_EVENT_LISTENERS = (function() {
let passive = false;
try {
const options = Object.defineProperty({}, 'passive', {
get: function() {
passive = true;
}
});
window.addEventListener('_', null, options);
window.removeEventListener('_', null, options);
} catch (error) {
// passive not supported
}
return passive;
})();