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

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 24 13:33:25 UTC 2020


 loleaflet/src/layer/SplitPanesContext.js |   40 +++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 10 deletions(-)

New commits:
commit bd928485c799feb9f6047374cfb10c3f357eeaba
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Fri Jul 24 09:28:13 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Fri Jul 24 15:33:07 2020 +0200

    split-panes: justify and compute both x/y snap positions...
    
    together and fire a single 'splitposchanged' instead of firing
    separately for each dimension. This is important at least in the case of
    changing zooms, where without this fix, the listeners will get
    incorrect(old) value of y split position for the first fire.
    
    Change-Id: Ic90aa74f9a57dd240a8a3038967c44cf89c3ff89
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99370
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/loleaflet/src/layer/SplitPanesContext.js b/loleaflet/src/layer/SplitPanesContext.js
index 74c54d778..01920ec8e 100644
--- a/loleaflet/src/layer/SplitPanesContext.js
+++ b/loleaflet/src/layer/SplitPanesContext.js
@@ -46,8 +46,10 @@ L.SplitPanesContext = L.Class.extend({
 
 	setSplitPos: function (splitX, splitY, forceUpdate) {
 
-		this.setHorizSplitPos(splitX, forceUpdate);
-		this.setVertSplitPos(splitY, forceUpdate);
+		var xchanged = this.setHorizSplitPos(splitX, forceUpdate, true /* noFire */);
+		var ychanged = this.setVertSplitPos(splitY, forceUpdate, true /* noFire */);
+		if (xchanged || ychanged)
+			this._map.fire('splitposchanged');
 	},
 
 	alignSplitPos: function () {
@@ -81,7 +83,7 @@ L.SplitPanesContext = L.Class.extend({
 			this._docLayer.getSnapDocPosY(split);
 	},
 
-	setHorizSplitPos: function (splitX, forceUpdate) {
+	setHorizSplitPos: function (splitX, forceUpdate, noFire) {
 
 		console.assert(typeof splitX === 'number', 'splitX must be a number');
 
@@ -89,16 +91,25 @@ L.SplitPanesContext = L.Class.extend({
 			if (forceUpdate || !this._docLayer.hasXSplitter()) {
 				this._updateXSplitter();
 			}
-			return;
+			return false;
 		}
 
-		this._splitPos.x = this.justifySplitPos(splitX, true /* isHoriz */);
+		var changed = false;
+		var newX = this.justifySplitPos(splitX, true /* isHoriz */);
+		if (newX !== this._splitPos.x) {
+			this._splitPos.x = newX;
+			changed = true;
+		}
 
 		this._updateXSplitter();
-		this._map.fire('splitposchanged');
+
+		if (!noFire)
+			this._map.fire('splitposchanged');
+
+		return changed;
 	},
 
-	setVertSplitPos: function (splitY, forceUpdate) {
+	setVertSplitPos: function (splitY, forceUpdate, noFire) {
 
 		console.assert(typeof splitY === 'number', 'splitY must be a number');
 
@@ -106,13 +117,22 @@ L.SplitPanesContext = L.Class.extend({
 			if (forceUpdate || !this._docLayer.hasYSplitter()) {
 				this._updateYSplitter();
 			}
-			return;
+			return false;
 		}
 
-		this._splitPos.y = this.justifySplitPos(splitY, false /* isHoriz */);
+		var changed = false;
+		var newY = this.justifySplitPos(splitY, false /* isHoriz */);
+		if (newY !== this._splitPos.y) {
+			this._splitPos.y = newY;
+			changed = true;
+		}
 
 		this._updateYSplitter();
-		this._map.fire('splitposchanged');
+
+		if (!noFire)
+			this._map.fire('splitposchanged');
+
+		return changed;
 	},
 
 	alignHorizSplitPos: function () {


More information about the Libreoffice-commits mailing list