[Libreoffice-commits] online.git: loleaflet/src

dewana-dewan iit2015097 at iiita.ac.in
Fri Mar 17 08:32:20 UTC 2017


 loleaflet/src/map/handler/Map.Scroll.js |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

New commits:
commit a3c1a685cd4107f229b97619bcce9a3646fc7730
Author: dewana-dewan <iit2015097 at iiita.ac.in>
Date:   Thu Mar 16 23:08:27 2017 +0530

    implemented zooming with Ctrl-<mousewheel>
    
    Change-Id: I27e53715719fd84b3e22940cc5688e87ae1f0805
    Reviewed-on: https://gerrit.libreoffice.org/35288
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index f7a98f3c..593e1dfb 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -38,7 +38,12 @@ L.Map.Scroll = L.Handler.extend({
 		var left = Math.max(debounce - (+new Date() - this._startTime), 0);
 
 		clearTimeout(this._timer);
-		this._timer = setTimeout(L.bind(this._performScroll, this), left);
+		if (e.ctrlKey) {
+			this._timer = setTimeout(L.bind(this._performZoom, this), left);
+		}
+		else {
+			this._timer = setTimeout(L.bind(this._performScroll, this), left);
+		}
 
 		L.DomEvent.stop(e);
 	},
@@ -53,6 +58,29 @@ L.Map.Scroll = L.Handler.extend({
 
 		if (!delta) { return; }
 		map.fire('scrollby', {x: 0, y: delta * scrollAmount});
+	},
+
+	_performZoom: function () {
+		var map = this._map,
+		    delta = this._delta,
+		    zoom = map.getZoom();
+
+		map.stop(); // stop panning and fly animations if any
+
+		delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta);
+		delta = Math.max(Math.min(delta, 4), -4);
+		delta = map._limitZoom(zoom + delta) - zoom;
+
+		this._delta = 0;
+		this._startTime = null;
+
+		if (!delta) { return; }
+
+		if (map.options.scrollWheelZoom === 'center') {
+			map.setZoom(zoom + delta);
+		} else {
+			map.setZoomAround(this._lastMousePos, zoom + delta);
+		}
 	}
 });
 


More information about the Libreoffice-commits mailing list