commit 001dda13c2e309ca3270e5edb71f4e02b9b6054d
parent 32c2619b3f3821f8eea222584400c2ebf389fa63
Author: Sergey Orlov <wladimirych@gmail.com>
Date: Sat, 2 May 2020 12:38:38 +0200
panoramas: disable keyboard control for mapy.cz panorama #379
mapy.cz library attaches events to window object, so they are fired
also when user presses hotkeys to switch layers.
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/lib/leaflet.control.panoramas/lib/mapycz/index.js b/src/lib/leaflet.control.panoramas/lib/mapycz/index.js
@@ -23,7 +23,15 @@ const Viewer = L.Evented.extend({
includes: [CloseButtonMixin, DateLabelMixin],
initialize: function(smap, container) {
+ // Disable keyboard events for panorama as they conflict with other hotkeys.
+ const orig_windowAddEventListener = window.addEventListener;
+ window.addEventListener = (function(type, ...args) {
+ if (!/^key/u.test(type)) {
+ orig_windowAddEventListener(type, ...args);
+ }
+ });
this.panorama = new smap.Pano.Scene(container);
+ window.addEventListener = orig_windowAddEventListener;
this.createDateLabel(container);
this.createCloseButton(container);
window.addEventListener('resize', this.resize.bind(this));