[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 11 18:24:16 UTC 2018


 loleaflet/src/map/Map.js |   35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 6c09b94a2a1136f93b039604289866048b8a514e
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Sat Sep 8 21:25:41 2018 -0400
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Sep 11 20:23:57 2018 +0200

    loleaflet: ensure map does not pan on resize
    
    Change-Id: I4644fce70026266798282fbab135aa9c6435e671
    Reviewed-on: https://gerrit.libreoffice.org/60209
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 79d70c5e5..944c9928f 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -350,12 +350,41 @@ L.Map = L.Evented.extend({
 		return this.panTo(newCenter, options);
 	},
 
-	invalidateSize: function () {
+	invalidateSize: function (options) {
 		if (!this._loaded) { return this; }
 
+		options = L.extend({
+			animate: false,
+			pan: false
+		}, options === true ? {animate: true} : options);
+
 		var oldSize = this.getSize();
 		this._sizeChanged = true;
-		var newSize = this.getSize();
+
+		var newSize = this.getSize(),
+		    oldCenter = oldSize.divideBy(2).round(),
+		    newCenter = newSize.divideBy(2).round(),
+		    offset = oldCenter.subtract(newCenter);
+
+		if (!offset.x && !offset.y) { return this; }
+
+		if (options.animate && options.pan) {
+			this.panBy(offset);
+
+		} else {
+			if (options.pan) {
+				this._rawPanBy(offset);
+			}
+
+			this.fire('move');
+
+			if (options.debounceMoveend) {
+				clearTimeout(this._sizeTimer);
+				this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
+			} else {
+				this.fire('moveend');
+			}
+		}
 
 		return this.fire('resize', {
 			oldSize: oldSize,
@@ -799,7 +828,7 @@ L.Map = L.Evented.extend({
 	_onResize: function () {
 		L.Util.cancelAnimFrame(this._resizeRequest);
 		this._resizeRequest = L.Util.requestAnimFrame(
-		        function () { this.invalidateSize(); }, this, false, this._container);
+			function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container);
 	},
 
 	_activate: function () {


More information about the Libreoffice-commits mailing list