[Libreoffice-commits] online.git: loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Tue Jun 30 10:23:28 PDT 2015
loleaflet/src/layer/tile/GridLayer.js | 11 +++--------
loleaflet/src/layer/tile/TileLayer.js | 21 ++++++++++++++++-----
2 files changed, 19 insertions(+), 13 deletions(-)
New commits:
commit d45a967e8d46b01f9c31bb37a803d9a02924c321
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Tue Jun 30 20:23:07 2015 +0300
Disable animFade when zooming + cache tiles from other zoom levels
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 1ac09e7..b095a2c 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -333,7 +333,6 @@ L.GridLayer = L.Layer.extend({
this._tileZoom = tileZoom;
if (tileZoomChanged) {
- this._map._fadeAnimated = true;
this._updateTileTwips();
this._updateMaxBounds();
}
@@ -697,11 +696,7 @@ L.GridLayer = L.Layer.extend({
this._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this);
} else {
tile.active = true;
- if (tile._skipPrune) {
- // avoid running the algorithm when we just replace a tile
- this._pruneTiles();
- }
- this._tiles[key]._skipPrune = false;
+ this._pruneTiles();
}
L.DomUtil.addClass(tile.el, 'leaflet-tile-loaded');
@@ -737,8 +732,8 @@ L.GridLayer = L.Layer.extend({
_twipsToCoords: function (twips) {
return new L.Point(
- twips.x / this._tileWidthTwips,
- twips.y / this._tileHeightTwips);
+ Math.round(twips.x / twips.tileWidth),
+ Math.round(twips.y / twips.tileHeight));
},
_coordsToTwips: function (coords) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index e63daf8..bb245ed 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -190,7 +190,7 @@ L.TileLayer = L.GridLayer.extend({
}
this._map._scrollContainer.onscroll = L.bind(this._onScroll, this);
this._map.on('zoomend resize', this._updateScrollOffset, this);
- this._map.on('zoomend', this._onUpdateCursor, this);
+ this._map.on('zoomstart zoomend', this._onZoom, this);
this._map.on('clearselection', this._clearSelections, this);
this._map.on('prevpart nextpart', this._onSwitchPart, this);
this._map.on('viewmode editmode', this._updateEditViewMode, this);
@@ -335,8 +335,6 @@ L.TileLayer = L.GridLayer.extend({
bottomRightTwips = topLeftTwips.add(offset);
var invalidBounds = new L.Bounds(topLeftTwips, bottomRightTwips);
- this._map._fadeAnimated = false;
-
for (var key in this._tiles) {
var coords = this._tiles[key].coords;
var point1 = this._coordsToTwips(coords);
@@ -399,7 +397,7 @@ L.TileLayer = L.GridLayer.extend({
}
else if (textMsg.startsWith('tile:')) {
command = this._parseServerCmd(textMsg);
- coords = this._twipsToCoords(new L.Point(command.x, command.y));
+ coords = this._twipsToCoords(command);
coords.z = command.zoom;
coords.part = command.part;
var data = bytes.subarray(index + 1);
@@ -414,10 +412,14 @@ L.TileLayer = L.GridLayer.extend({
var tile = this._tiles[key];
if (tile) {
if (tile.el.src) {
- this._tiles[key]._skipPrune = true;
+ this._map._fadeAnimated = false;
}
tile.el.src = 'data:image/png;base64,' + window.btoa(strBytes);
}
+ else {
+ this._tileCache[key] = 'data:image/png;base64,' + window.btoa(strBytes);
+ }
+
}
else if (textMsg.startsWith('textselection:')) {
strTwips = textMsg.match(/\d+/g);
@@ -995,6 +997,15 @@ L.TileLayer = L.GridLayer.extend({
else {
e.clipboardData.setData('text/plain', this._selectionTextContent);
}
+ },
+
+ _onZoom: function (e) {
+ if (e.type === 'zoomstart') {
+ this._fadeAnimated = false;
+ }
+ else if (e.type === 'zoomend') {
+ this._onUpdateCursor();
+ }
}
});
More information about the Libreoffice-commits
mailing list