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

Henry Castro hcastro at collabora.com
Fri Apr 21 13:08:14 UTC 2017


 loleaflet/src/layer/AnnotationManager.js    |    9 +++++++++
 loleaflet/src/layer/tile/WriterTileLayer.js |    9 ++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

New commits:
commit ef98a49066b5fc76544a0c63019fc63548b6bcb2
Author: Henry Castro <hcastro at collabora.com>
Date:   Thu Apr 20 21:56:07 2017 -0400

    loleaflet: update document size when insert new annotation
    
    Change-Id: Iaaca82aba1c04de336e89ff4e854cc9632fbfc53
    Reviewed-on: https://gerrit.libreoffice.org/36759
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index 88fbcaba..88cc2c6a 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -210,6 +210,12 @@ L.AnnotationManager = L.Class.extend({
 		this.layout();
 	},
 
+	updateDocBounds: function (count, extraSize) {
+		if (this._items.length === count) {
+			this._map._docLayer._updateMaxBounds(true, extraSize);
+		}
+	},
+
 	layoutUp: function (commentThread, latLng, layoutBounds) {
 		if (commentThread.length <= 0)
 			return;
@@ -473,6 +479,7 @@ L.AnnotationManager = L.Class.extend({
 			if (this._selected && !this._selected.isEdit()) {
 				this._map.focus();
 			}
+			this.updateDocBounds(1);
 			this.layout();
 		} else if (action === 'Remove') {
 			id = changetrack ? 'change-' + obj.redline.index : obj.comment.id;
@@ -480,6 +487,7 @@ L.AnnotationManager = L.Class.extend({
 			if (removed) {
 				this.adjustParentRemove(removed);
 				this._map.removeLayer(this.removeItem(id));
+				this.updateDocBounds(0);
 				if (this._selected === removed) {
 					this.unselect();
 				} else {
@@ -508,6 +516,7 @@ L.AnnotationManager = L.Class.extend({
 	_onAnnotationCancel: function (e) {
 		if (e.annotation._data.id === 'new') {
 			this._map.removeLayer(this.removeItem(e.annotation._data.id));
+			this.updateDocBounds(0);
 		}
 		if (this._selected === e.annotation) {
 			this.unselect();
diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js
index b45f584d..5610d010 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -12,6 +12,7 @@ L.WriterTileLayer = L.TileLayer.extend({
 			comment.anchorPix = this._twipsToPixels(comment.anchorPos.min);
 		}
 		if (comment.anchorPos) {
+			this._annotations.updateDocBounds(0, this._annotations.options.extraSize);
 			this._annotations.modify(this._annotations.add(comment));
 		}
 	},
@@ -229,9 +230,11 @@ L.WriterTileLayer = L.TileLayer.extend({
 		this._update();
 	},
 
-	_updateMaxBounds: function (sizeChanged) {
-		var extraSize = this._annotations && this._annotations._items.length > 0 ?
-			this._annotations.options.extraSize : null;
+	_updateMaxBounds: function (sizeChanged, extraSize) {
+		if (!extraSize) {
+			extraSize = this._annotations && this._annotations._items.length > 0 ?
+				this._annotations.options.extraSize : null;
+		}
 		L.GridLayer.prototype._updateMaxBounds.call(this, sizeChanged, extraSize, {panInside: false});
 	}
 });


More information about the Libreoffice-commits mailing list