Merge pull request #10286 from ahocevar/passive
Use passive option to avoid Chrome warning
This commit is contained in:
@@ -22,7 +22,7 @@ import {listen, unlistenByKey} from './events.js';
|
|||||||
import EventType from './events/EventType.js';
|
import EventType from './events/EventType.js';
|
||||||
import {clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
|
import {clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
|
||||||
import {TRUE} from './functions.js';
|
import {TRUE} from './functions.js';
|
||||||
import {DEVICE_PIXEL_RATIO, IMAGE_DECODE} from './has.js';
|
import {DEVICE_PIXEL_RATIO, IMAGE_DECODE, PASSIVE_EVENT_LISTENERS} from './has.js';
|
||||||
import LayerGroup from './layer/Group.js';
|
import LayerGroup from './layer/Group.js';
|
||||||
import {hasArea} from './size.js';
|
import {hasArea} from './size.js';
|
||||||
import {DROP} from './structs/PriorityQueue.js';
|
import {DROP} from './structs/PriorityQueue.js';
|
||||||
@@ -313,7 +313,8 @@ class PluggableMap extends BaseObject {
|
|||||||
|
|
||||||
const handleBrowserEvent = this.handleBrowserEvent.bind(this);
|
const handleBrowserEvent = this.handleBrowserEvent.bind(this);
|
||||||
this.viewport_.addEventListener(EventType.CONTEXTMENU, handleBrowserEvent, false);
|
this.viewport_.addEventListener(EventType.CONTEXTMENU, handleBrowserEvent, false);
|
||||||
this.viewport_.addEventListener(EventType.WHEEL, handleBrowserEvent, false);
|
this.viewport_.addEventListener(EventType.WHEEL, handleBrowserEvent,
|
||||||
|
PASSIVE_EVENT_LISTENERS ? {passive: false} : false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Collection<import("./control/Control.js").default>}
|
* @type {Collection<import("./control/Control.js").default>}
|
||||||
|
|||||||
@@ -44,3 +44,23 @@ export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
export const IMAGE_DECODE = typeof Image !== 'undefined' && Image.prototype.decode;
|
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;
|
||||||
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user