Conditional default prevention instead of touch-action: none
This commit is contained in:
@@ -131,17 +131,6 @@ import {toUserCoordinate, fromUserCoordinate} from './proj.js';
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} element Element.
|
||||
* @param {string} touchAction Value for `touch-action'.
|
||||
*/
|
||||
function setTouchAction(element, touchAction) {
|
||||
element.style.msTouchAction = touchAction;
|
||||
element.style.touchAction = touchAction;
|
||||
element.setAttribute('touch-action', touchAction);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fires import("./MapBrowserEvent.js").MapBrowserEvent
|
||||
* @fires import("./MapEvent.js").MapEvent
|
||||
@@ -305,12 +294,6 @@ class PluggableMap extends BaseObject {
|
||||
*/
|
||||
this.keyHandlerKeys_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?Array<import("./events.js").EventsKey>}
|
||||
*/
|
||||
this.focusHandlerKeys_ = null;
|
||||
|
||||
const handleBrowserEvent = this.handleBrowserEvent.bind(this);
|
||||
this.viewport_.addEventListener(EventType.CONTEXTMENU, handleBrowserEvent, false);
|
||||
this.viewport_.addEventListener(EventType.WHEEL, handleBrowserEvent,
|
||||
@@ -939,6 +922,7 @@ class PluggableMap extends BaseObject {
|
||||
const type = opt_type || browserEvent.type;
|
||||
const mapBrowserEvent = new MapBrowserEvent(type, this, browserEvent);
|
||||
this.handleMapBrowserEvent(mapBrowserEvent);
|
||||
browserEvent.preventDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1044,12 +1028,6 @@ class PluggableMap extends BaseObject {
|
||||
targetElement = this.getTargetElement();
|
||||
}
|
||||
|
||||
if (this.focusHandlerKeys_) {
|
||||
for (let i = 0, ii = this.focusHandlerKeys_.length; i < ii; ++i) {
|
||||
unlistenByKey(this.focusHandlerKeys_[i]);
|
||||
}
|
||||
this.focusHandlerKeys_ = null;
|
||||
}
|
||||
if (this.keyHandlerKeys_) {
|
||||
for (let i = 0, ii = this.keyHandlerKeys_.length; i < ii; ++i) {
|
||||
unlistenByKey(this.keyHandlerKeys_[i]);
|
||||
@@ -1078,15 +1056,6 @@ class PluggableMap extends BaseObject {
|
||||
if (!this.renderer_) {
|
||||
this.renderer_ = this.createRenderer();
|
||||
}
|
||||
let hasFocus = true;
|
||||
if (targetElement.hasAttribute('tabindex')) {
|
||||
hasFocus = document.activeElement === targetElement;
|
||||
this.focusHandlerKeys_ = [
|
||||
listen(targetElement, EventType.FOCUS, setTouchAction.bind(this, this.viewport_, 'none')),
|
||||
listen(targetElement, EventType.BLUR, setTouchAction.bind(this, this.viewport_, 'auto'))
|
||||
];
|
||||
}
|
||||
setTouchAction(this.viewport_, hasFocus ? 'none' : 'auto');
|
||||
|
||||
const keyboardEventTarget = !this.keyboardEventTarget_ ?
|
||||
targetElement : this.keyboardEventTarget_;
|
||||
|
||||
Reference in New Issue
Block a user