[Libreoffice-commits] online.git: loleaflet/src
Miklos Vajna
vmiklos at collabora.co.uk
Tue Feb 2 13:11:41 UTC 2016
loleaflet/src/layer/tile/TileLayer.js | 14 ++++++++++++++
1 file changed, 14 insertions(+)
New commits:
commit 1e3432b7e9674b72a8ae28867fa311614116fc59
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Feb 2 14:08:18 2016 +0100
loleaflet: initial support for the clientvisiblearea command
This is enough, so that e.g. pagedown jumps down about a visual page
correctly.
Areas where this could be improved further in the future:
- Currently the visual area is only updated on zoom change. Perhaps it
would be better to update it when the visual area really changes, i.e.
on scroll or resize. But the cost of this only makes sense if
something on the server side needs the correct position or width as
well, not only the height (as pgdown does).
- Currently the visual area is sent only before a key command (if it's
dirty), is there a use-case when sending it also before e.g. a mouse
click is also useful?
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 832f531..220efc8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -124,6 +124,8 @@ L.TileLayer = L.GridLayer.extend({
'tilepixelheight=' + this.options.tileSize + ' ' +
'tiletwipwidth=' + this.options.tileWidthTwips + ' ' +
'tiletwipheight=' + this.options.tileHeightTwips;
+ // Mark visible area as dirty by default.
+ this._clientVisibleArea = true;
},
onAdd: function (map) {
@@ -777,6 +779,16 @@ L.TileLayer = L.GridLayer.extend({
this._map._socket.sendMessage('clientzoom ' + this._clientZoom);
this._clientZoom = null;
}
+ if (this._clientVisibleArea) {
+ // Visible area is dirty, update it on the server.
+ var visibleArea = this._map._container.getBoundingClientRect();
+ var pos = this._pixelsToTwips(new L.Point(visibleArea.left, visibleArea.top));
+ var size = this._pixelsToTwips(new L.Point(visibleArea.width, visibleArea.height));
+ var payload = 'clientvisiblearea x=' + Math.round(pos.x) + ' y=' + Math.round(pos.y) +
+ ' width=' + Math.round(size.x) + ' height=' + Math.round(size.y);
+ this._map._socket.sendMessage(payload);
+ this._clientVisibleArea = null;
+ }
this._map._socket.sendMessage('key type=' + type +
' char=' + charcode + ' key=' + keycode);
},
@@ -1256,6 +1268,8 @@ L.TileLayer = L.GridLayer.extend({
'tilepixelheight=' + this._tileSize + ' ' +
'tiletwipwidth=' + this._tileWidthTwips + ' ' +
'tiletwipheight=' + this._tileHeightTwips;
+ // Zoom changed, mark visible area as dirty.
+ this._clientVisibleArea = true;
}
});
More information about the Libreoffice-commits
mailing list