Conditional default prevention instead of touch-action: none

This commit is contained in:
Andreas Hocevar
2019-11-25 00:27:51 +01:00
parent 0ed57b8b7c
commit 88b8b2f7cb
10 changed files with 103 additions and 49 deletions

View File

@@ -0,0 +1,29 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import OSM from '../src/ol/source/OSM.js';
import {defaults, DragPan, MouseWheelZoom} from '../src/ol/interaction.js';
import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
const map = new Map({
interactions: defaults({dragPan: false, mouseWheelZoom: false}).extend([
new DragPan({
condition: function(event) {
return this.getPointerCount() === 2 || platformModifierKeyOnly(event);
}
}),
new MouseWheelZoom({
condition: platformModifierKeyOnly
})
]),
layers: [
new TileLayer({
source: new OSM()
})
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});