1
0
Fork 0
forked from 0x2620/oxjs

use passive for touch events if possible, fixes #3059

This commit is contained in:
j 2017-11-06 07:42:51 +02:00
commit 0a9c30d1dc
2 changed files with 29 additions and 5 deletions

View file

@ -20,11 +20,21 @@ if ($.event.fixHooks) {
}
}
var supportsPassive = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function() {
supportsPassive = true;
}
});
window.addEventListener("test", null, opts);
} catch (e) {}
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
this.addEventListener( types[--i], handler, supportsPassive ? { passive: true } : false );
}
} else {
this.onmousewheel = handler;
@ -34,7 +44,7 @@ $.event.special.mousewheel = {
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
this.removeEventListener( types[--i], handler, supportsPassive ? { passive: true } : false );
}
} else {
this.onmousewheel = null;