loleaflet/src/core/Log.js | 2 +- loleaflet/src/layer/tile/GridLayer.js | 8 ++++---- loleaflet/src/layer/tile/TileLayer.js | 28 ++++++++++++++++++---------- loleaflet/src/map/Map.js | 4 ++-- 4 files changed, 25 insertions(+), 17 deletions(-)
New commits: commit 299df144bc511fdc19dd0eed631200f3d0f31b13 Author: Mihai Varga <mihai.va...@collabora.com> Date: Fri Aug 7 09:57:45 2015 +0300 loleaflet: fixed jslint errors diff --git a/loleaflet/src/core/Log.js b/loleaflet/src/core/Log.js index e8f731f..551cff7 100644 --- a/loleaflet/src/core/Log.js +++ b/loleaflet/src/core/Log.js @@ -5,7 +5,7 @@ L.Log = { log: function (msg, direction, tileCoords, time) { if (!time) { - var time = Date.now(); + time = Date.now(); } if (!this._logs) { this._logs = []; diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index 1a983d1..3b38029 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -768,11 +768,11 @@ L.GridLayer = L.Layer.extend({ if (!this._preFetchBorder) { if (this._currentPart !== this._preFetchPart) { // all tiles from the new part have to be pre-fetched - tileBorder = this._preFetchBorder = new L.Bounds(new L.Point(0, 0), new L.Point(0, 0)); + var tileBorder = this._preFetchBorder = new L.Bounds(new L.Point(0, 0), new L.Point(0, 0)); } else { - var pixelBounds = this._map.getPixelBounds(center, zoom), - tileBorder = this._pxBoundsToTileRange(pixelBounds); + var pixelBounds = this._map.getPixelBounds(center, zoom); + tileBorder = this._pxBoundsToTileRange(pixelBounds); this._preFetchBorder = tileBorder; } } @@ -904,7 +904,7 @@ L.GridLayer = L.Layer.extend({ } var interval = 750; var idleTime = 5000; - this._preFetchIdle = setTimeout(L.bind( function () { + this._preFetchIdle = setTimeout(L.bind(function () { this._tilesPreFetcher = setInterval(L.bind(this._preFetchTiles, this), interval); }, this), idleTime); } diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 774ced8..dfa0572 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -312,7 +312,7 @@ L.TileLayer = L.GridLayer.extend({ } var cursorPos = this._map.project(this._visibleCursor.getNorthWest()); cursorPos = cursorPos.divideBy(this._tileSize); - toRequest.sort(function(x, y) {return x.coords.distanceTo(cursorPos) - y.coords.distanceTo(cursorPos)}); + toRequest.sort(function(x, y) {return x.coords.distanceTo(cursorPos) - y.coords.distanceTo(cursorPos);}); for (var i = 0; i < toRequest.length; i++) { this.sendMessage(toRequest[i].msg, toRequest[i].key); } @@ -403,7 +403,7 @@ L.TileLayer = L.GridLayer.extend({ // read the tile data var strBytes = ''; - for (var i = 0; i < data.length; i++) { + for (i = 0; i < data.length; i++) { strBytes += String.fromCharCode(data[i]); } @@ -572,7 +572,7 @@ L.TileLayer = L.GridLayer.extend({ // remove newline characters command.type = tokens[i].substring(5).replace(/(\r\n|\n|\r)/gm, ''); } - else if (tokens[i].substring(0,9) === 'prefetch=') { + else if (tokens[i].substring(0, 9) === 'prefetch=') { command.preFetch = tokens[i].substring(9); } } diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index aa7333e..500ffae 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -752,11 +752,11 @@ L.Map = L.Evented.extend({ return Math.max(min, Math.min(max, zoom)); }, - _onSocketError: function (e) { + _onSocketError: function () { this.fire('error', {msg: 'Socket connection error'}); }, - _onSocketClose: function (e) { + _onSocketClose: function () { this.fire('error', {msg: 'Socket connection closed'}); } }); commit ac1efd969ff521d5d6d85487312f34b580944814 Author: Mihai Varga <mihai.va...@collabora.com> Date: Wed Aug 5 17:51:30 2015 +0300 loleaflet: request tiles closer to the cursor first diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 1372443..774ced8 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -278,6 +278,7 @@ L.TileLayer = L.GridLayer.extend({ var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest()); var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast()); var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight); + var toRequest = []; for (var key in this._tiles) { var coords = this._tiles[key].coords; @@ -292,14 +293,15 @@ L.TileLayer = L.GridLayer.extend({ this._tiles[key]._invalidCount = 1; } if (visibleArea.intersects(bounds)) { - this.sendMessage('tile ' + - 'part=' + coords.part + ' ' + - 'width=' + this._tileSize + ' ' + - 'height=' + this._tileSize + ' ' + - 'tileposx=' + tileTopLeft.x + ' ' + - 'tileposy=' + tileTopLeft.y + ' ' + - 'tilewidth=' + this._tileWidthTwips + ' ' + - 'tileheight=' + this._tileHeightTwips, key); + var msg = 'tile ' + + 'part=' + coords.part + ' ' + + 'width=' + this._tileSize + ' ' + + 'height=' + this._tileSize + ' ' + + 'tileposx=' + tileTopLeft.x + ' ' + + 'tileposy=' + tileTopLeft.y + ' ' + + 'tilewidth=' + this._tileWidthTwips + ' ' + + 'tileheight=' + this._tileHeightTwips; + toRequest.push({msg: msg, key: key, coords: coords}); } else { // tile outside of the visible area, just remove it @@ -308,6 +310,12 @@ L.TileLayer = L.GridLayer.extend({ } } } + var cursorPos = this._map.project(this._visibleCursor.getNorthWest()); + cursorPos = cursorPos.divideBy(this._tileSize); + toRequest.sort(function(x, y) {return x.coords.distanceTo(cursorPos) - y.coords.distanceTo(cursorPos)}); + for (var i = 0; i < toRequest.length; i++) { + this.sendMessage(toRequest[i].msg, toRequest[i].key); + } for (key in this._tileCache) { // compute the rectangle that each tile covers in the document based // on the zoom level _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits