From e965983322e2941403ee7d7ea474a9ac5f23b211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Thu, 16 Nov 2017 01:04:31 +0100 Subject: [PATCH] continuous zooming in editor --- src/c3nav/editor/static/editor/js/editor.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/c3nav/editor/static/editor/js/editor.js b/src/c3nav/editor/static/editor/js/editor.js index f4caa166..d383d156 100644 --- a/src/c3nav/editor/static/editor/js/editor.js +++ b/src/c3nav/editor/static/editor/js/editor.js @@ -12,7 +12,7 @@ editor = { minZoom: 0, crs: L.CRS.Simple, editable: true, - closePopupOnClick: false + zoomSnap: 0 }); if (L.Browser.chrome && !('ontouchstart' in window)) { $('.leaflet-touch').removeClass('leaflet-touch'); @@ -21,6 +21,18 @@ editor = { editor.map.on('click', function () { editor.map.doubleClickZoom.enable(); }); + + /* + * Fix scroll wheel zoom on precise scrolling devices + */ + var originalPerformZoom = L.Map.ScrollWheelZoom.prototype._performZoom; + L.Map.ScrollWheelZoom.include({ + _performZoom: function () { + if (this._delta) this._delta = (this._delta > 0) ? Math.max(this._delta, 60) : Math.min(this._delta, -60); + originalPerformZoom.call(this); + } + }); + window.onbeforeunload = editor._onbeforeunload; L.control.scale({imperial: false}).addTo(editor.map);