Add focus condition, e.g. for wheel zoom

This commit is contained in:
Andreas Hocevar
2018-02-27 14:36:08 +01:00
parent 795ef70bf9
commit 2d67c15ea9
3 changed files with 29 additions and 8 deletions

View File

@@ -41,6 +41,19 @@ export const altShiftKeysOnly = function(mapBrowserEvent) {
};
/**
* Return `true` if the map has the focus. This condition requires a map target
* element with a `tabindex` attribute, e.g. `<div id="map" tabindex="1">`.
*
* @param {ol.MapBrowserEvent} event Map browser event.
* @return {boolean} The map has the focus.
* @api
*/
export const focus = function(event) {
return event.target.getTargetElement() === document.activeElement;
};
/**
* Return always true.
*