Skip to content

Commit 2c6925d

Browse files
committed
supported map mouse wheel zoom only when map has focus
1 parent 4718d00 commit 2c6925d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

assets/javascripts/app.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,21 @@ var App = (function ($, publ) {
163163
}
164164
});
165165
}
166-
166+
// For map div focus settings
167+
if (options.target) {
168+
if (options.target.getAttribute("tabindex") == null) {
169+
options.target.setAttribute("tabindex", "0")
170+
}
171+
}
167172
map = new ol.Map({
168173
target: options.target,
169174
layers: layerArr,
170-
interactions: ol.interaction.defaults({mouseWheelZoom:false}),
175+
interactions: ol.interaction.defaults({mouseWheelZoom:false}).extend([
176+
new ol.interaction.MouseWheelZoom({
177+
constrainResolution: true, // force zooming to a integer zoom
178+
condition: ol.events.condition.focus // only wheel/trackpad zoom when the map has the focus
179+
})
180+
]),
171181
controls: ol.control.defaults({
172182
attributionOptions: ({
173183
collapsible: false

0 commit comments

Comments
 (0)