use passive for touch events if possible, fixes #3059
This commit is contained in:
parent
b11d6a81fe
commit
0a9c30d1dc
2 changed files with 29 additions and 5 deletions
|
@ -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 = {
|
$.event.special.mousewheel = {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
if ( this.addEventListener ) {
|
if ( this.addEventListener ) {
|
||||||
for ( var i=types.length; i; ) {
|
for ( var i=types.length; i; ) {
|
||||||
this.addEventListener( types[--i], handler, false );
|
this.addEventListener( types[--i], handler, supportsPassive ? { passive: true } : false );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.onmousewheel = handler;
|
this.onmousewheel = handler;
|
||||||
|
@ -34,7 +44,7 @@ $.event.special.mousewheel = {
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
if ( this.removeEventListener ) {
|
if ( this.removeEventListener ) {
|
||||||
for ( var i=types.length; i; ) {
|
for ( var i=types.length; i; ) {
|
||||||
this.removeEventListener( types[--i], handler, false );
|
this.removeEventListener( types[--i], handler, supportsPassive ? { passive: true } : false );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.onmousewheel = null;
|
this.onmousewheel = null;
|
||||||
|
|
|
@ -2,6 +2,15 @@
|
||||||
|
|
||||||
(function(_) {
|
(function(_) {
|
||||||
var noTooltipEvents = {};
|
var noTooltipEvents = {};
|
||||||
|
var supportsPassive = false;
|
||||||
|
try {
|
||||||
|
var opts = Object.defineProperty({}, 'passive', {
|
||||||
|
get: function() {
|
||||||
|
supportsPassive = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.addEventListener("test", null, opts);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.Element <f> Basic UI element object
|
Ox.Element <f> Basic UI element object
|
||||||
|
@ -128,10 +137,15 @@
|
||||||
.on({
|
.on({
|
||||||
mousedown: onMousedown,
|
mousedown: onMousedown,
|
||||||
mousewheel: onMousewheel,
|
mousewheel: onMousewheel,
|
||||||
touchend: onTouchend,
|
//touchend: onTouchend,
|
||||||
touchmove: onTouchmove,
|
//touchmove: onTouchmove,
|
||||||
touchstart: onTouchstart
|
//touchstart: onTouchstart
|
||||||
});
|
});
|
||||||
|
|
||||||
|
that.$element[0].addEventListener('touchend', onTouchend, supportsPassive ? { passive: true } : false );
|
||||||
|
that.$element[0].addEventListener('touchmove', onTouchmove, supportsPassive ? { passive: true } : false );
|
||||||
|
that.$element[0].addEventListener('touchstart', onTouchstart, supportsPassive ? { passive: true } : false );
|
||||||
|
|
||||||
that[0] = that.$element[0];
|
that[0] = that.$element[0];
|
||||||
that.length = 1;
|
that.length = 1;
|
||||||
that.self = function _self() {
|
that.self = function _self() {
|
||||||
|
|
Loading…
Reference in a new issue