Merge pull request #10291 from ahocevar/tabindex

tabindex without focus condition
This commit is contained in:
Andreas Hocevar
2019-11-14 09:07:37 +01:00
committed by GitHub
5 changed files with 42 additions and 22 deletions

View File

@@ -3,7 +3,7 @@
*/
import {scale as scaleCoordinate, rotate as rotateCoordinate} from '../coordinate.js';
import {easeOut} from '../easing.js';
import {noModifierKeys, primaryAction} from '../events/condition.js';
import {noModifierKeys, primaryAction, focus} from '../events/condition.js';
import {FALSE} from '../functions.js';
import PointerInteraction, {centroid as centroidFromPointers} from './Pointer.js';
@@ -69,6 +69,20 @@ class DragPan extends PointerInteraction {
}
/**
* @private
* @param {import("../MapBrowserEvent").default} mapBrowserEvent Event.
* @return {boolean} Condition passes.
*/
conditionInternal_(mapBrowserEvent) {
let pass = true;
if (mapBrowserEvent.map.getTargetElement().hasAttribute('tabindex')) {
pass = focus(mapBrowserEvent);
}
return pass && this.condition_(mapBrowserEvent);
}
/**
* @inheritDoc
*/
@@ -145,7 +159,7 @@ class DragPan extends PointerInteraction {
* @inheritDoc
*/
handleDownEvent(mapBrowserEvent) {
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
if (this.targetPointers.length > 0 && this.conditionInternal_(mapBrowserEvent)) {
const map = mapBrowserEvent.map;
const view = map.getView();
this.lastCentroid = null;

View File

@@ -1,7 +1,7 @@
/**
* @module ol/interaction/MouseWheelZoom
*/
import {always} from '../events/condition.js';
import {always, focus} from '../events/condition.js';
import EventType from '../events/EventType.js';
import {DEVICE_PIXEL_RATIO, FIREFOX} from '../has.js';
import Interaction, {zoomByDelta} from './Interaction.js';
@@ -134,6 +134,20 @@ class MouseWheelZoom extends Interaction {
}
/**
* @private
* @param {import("../MapBrowserEvent").default} mapBrowserEvent Event.
* @return {boolean} Condition passes.
*/
conditionInternal_(mapBrowserEvent) {
let pass = true;
if (mapBrowserEvent.map.getTargetElement().hasAttribute('tabindex')) {
pass = focus(mapBrowserEvent);
}
return pass && this.condition_(mapBrowserEvent);
}
/**
* @private
*/
@@ -149,7 +163,7 @@ class MouseWheelZoom extends Interaction {
* @override
*/
handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) {
if (!this.conditionInternal_(mapBrowserEvent)) {
return true;
}
const type = mapBrowserEvent.type;