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

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 15 12:06:16 UTC 2020


 loleaflet/src/control/Control.StatusBar.js |   35 +++++++++++++++++++----------
 loleaflet/src/map/Map.js                   |    7 ++++-
 2 files changed, 30 insertions(+), 12 deletions(-)

New commits:
commit 8c70e6a8f6fb8a36ade74ab4c6b4e5044e09064d
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Apr 15 13:30:45 2020 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Apr 15 14:05:58 2020 +0200

    tdf#128507: Increase max zoom to 400%
    
    Also add rounded-to-five labels for the already previously possible
    two smallest zoom levels (35% and 40%).
    
    Change-Id: I8c7293093e8fe70a4b50081a0a3ac4f96c8486ba
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92259
    Tested-by: Tor Lillqvist <tml at collabora.com>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/loleaflet/src/control/Control.StatusBar.js b/loleaflet/src/control/Control.StatusBar.js
index 544302d2d..bfe2866ae 100644
--- a/loleaflet/src/control/Control.StatusBar.js
+++ b/loleaflet/src/control/Control.StatusBar.js
@@ -266,6 +266,8 @@ L.Control.StatusBar = L.Control.extend({
 						selected: 'zoom100',
 						mobile: false,
 						items: [
+							{ id: 'zoom35', text: '35', scale: 4},
+							{ id: 'zoom40', text: '40', scale: 5},
 							{ id: 'zoom50', text: '50', scale: 6},
 							{ id: 'zoom60', text: '60', scale: 7},
 							{ id: 'zoom70', text: '70', scale: 8},
@@ -274,7 +276,11 @@ L.Control.StatusBar = L.Control.extend({
 							{ id: 'zoom120', text: '120', scale: 11},
 							{ id: 'zoom150', text: '150', scale: 12},
 							{ id: 'zoom175', text: '175', scale: 13},
-							{ id: 'zoom200', text: '200', scale: 14}
+							{ id: 'zoom200', text: '200', scale: 14},
+							{ id: 'zoom235', text: '235', scale: 15},
+							{ id: 'zoom280', text: '280', scale: 16},
+							{ id: 'zoom335', text: '335', scale: 17},
+							{ id: 'zoom400', text: '400', scale: 18},
 						]
 					},
 					{type: 'button',  id: 'zoomin', img: 'zoomin', hint: _UNO('.uno:ZoomPlus')}
@@ -344,18 +350,25 @@ L.Control.StatusBar = L.Control.extend({
 			var zoomPercent = 100;
 			var zoomSelected = null;
 			switch (that.map.getZoom()) {
-			case 6:  zoomPercent =  50; zoomSelected = 'zoom50'; break;
-			case 7:  zoomPercent =  60; zoomSelected = 'zoom60'; break;
-			case 8:  zoomPercent =  70; zoomSelected = 'zoom70'; break;
-			case 9:  zoomPercent =  85; zoomSelected = 'zoom85'; break;
-			case 10: zoomPercent = 100; zoomSelected = 'zoom100'; break;
-			case 11: zoomPercent = 120; zoomSelected = 'zoom120'; break;
-			case 12: zoomPercent = 150; zoomSelected = 'zoom150'; break;
-			case 13: zoomPercent = 175; zoomSelected = 'zoom175'; break;
-			case 14: zoomPercent = 200; zoomSelected = 'zoom200'; break;
+			case 4:  zoomPercent =  35; zoomSelected = 'zoom35'; break;  // 0.3535
+			case 5:  zoomPercent =  40; zoomSelected = 'zoom40'; break;  // 0.4204
+			case 6:  zoomPercent =  50; zoomSelected = 'zoom50'; break;  // 0.5
+			case 7:  zoomPercent =  60; zoomSelected = 'zoom60'; break;  // 0.5946
+			case 8:  zoomPercent =  70; zoomSelected = 'zoom70'; break;  // 0.7071
+			case 9:  zoomPercent =  85; zoomSelected = 'zoom85'; break;  // 0.8409
+			case 10: zoomPercent = 100; zoomSelected = 'zoom100'; break; // 1
+			case 11: zoomPercent = 120; zoomSelected = 'zoom120'; break; // 1.1892
+			// Why do we call this 150% even if it is actually closer to 140%
+			case 12: zoomPercent = 150; zoomSelected = 'zoom150'; break; // 1.4142
+			case 13: zoomPercent = 170; zoomSelected = 'zoom170'; break; // 1.6818
+			case 14: zoomPercent = 200; zoomSelected = 'zoom200'; break; // 2
+			case 15: zoomPercent = 235; zoomSelected = 'zoom235'; break; // 2.3784
+			case 16: zoomPercent = 280; zoomSelected = 'zoom280'; break; // 2.8284
+			case 17: zoomPercent = 335; zoomSelected = 'zoom335'; break; // 3.3636
+			case 18: zoomPercent = 400; zoomSelected = 'zoom400'; break; // 4
 			default:
 				var zoomRatio = that.map.getZoomScale(that.map.getZoom(), that.map.options.zoom);
-				zoomPercent = Math.round(zoomRatio * 100) + '%';
+				zoomPercent = Math.round(zoomRatio * 100);
 				break;
 			}
 			w2ui['actionbar'].set('zoom', {text: zoomPercent, selected: zoomSelected});
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index f5699bca3..ca4550593 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -31,8 +31,13 @@ L.Map = L.Evented.extend({
 		crs: L.CRS.Simple,
 		center: [0, 0],
 		zoom: 10,
+		// These zoom values are on a logarithmic scale. Each step away from the default 10
+		// (meaning 1 = 100%) is a multiplication by or division with pow(2,1/4). pow(2,1/4)
+		// is approximately 1.2. Thus 4 corresponds to six steps of division by pow(2,1/4) =
+		// 35%. 18 corresponds to 8 steps of multiplication by pow(2,1/4) = 400%. The
+		// percentages available are then rounded to the nearest five percent.
 		minZoom: 4,
-		maxZoom: 14,
+		maxZoom: 18,
 		maxBounds: L.latLngBounds([0, 0], [-100, 100]),
 		fadeAnimation: false, // Not useful for typing.
 		trackResize: true,


More information about the Libreoffice-commits mailing list