style: lint fix all files

Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
This commit is contained in:
Vinayak Kulkarni 2022-09-20 13:01:05 +05:30
parent f61e333b29
commit b5e30d69ee
No known key found for this signature in database
GPG key ID: 0FE8ABF8260A1552
6 changed files with 87387 additions and 259 deletions

View file

@ -12,32 +12,32 @@ L.TileLayer.mergeOptions({
}); });
L.TileLayer.include({ L.TileLayer.include({
_onUpdateLevel: function(z, zoom) { _onUpdateLevel: function (z, zoom) {
if (this.options.dumpToCanvas) { if (this.options.dumpToCanvas) {
this._levels[z].canvas.style.zIndex = this._levels[z].canvas.style.zIndex =
this.options.maxZoom - Math.abs(zoom - z); this.options.maxZoom - Math.abs(zoom - z);
} }
}, },
_onRemoveLevel: function(z) { _onRemoveLevel: function (z) {
if (this.options.dumpToCanvas) { if (this.options.dumpToCanvas) {
L.DomUtil.remove(this._levels[z].canvas); L.DomUtil.remove(this._levels[z].canvas);
} }
}, },
_onCreateLevel: function(level) { _onCreateLevel: function (level) {
if (this.options.dumpToCanvas) { if (this.options.dumpToCanvas) {
level.canvas = L.DomUtil.create( level.canvas = L.DomUtil.create(
"canvas", 'canvas',
"leaflet-tile-container leaflet-zoom-animated", 'leaflet-tile-container leaflet-zoom-animated',
this._container this._container,
); );
level.ctx = level.canvas.getContext("2d"); level.ctx = level.canvas.getContext('2d');
this._resetCanvasSize(level); this._resetCanvasSize(level);
} }
}, },
_removeTile: function(key) { _removeTile: function (key) {
if (this.options.dumpToCanvas) { if (this.options.dumpToCanvas) {
var tile = this._tiles[key]; var tile = this._tiles[key];
var level = this._levels[tile.coords.z]; var level = this._levels[tile.coords.z];
@ -56,7 +56,7 @@ L.TileLayer.include({
L.GridLayer.prototype._removeTile.call(this, key); L.GridLayer.prototype._removeTile.call(this, key);
}, },
_resetCanvasSize: function(level) { _resetCanvasSize: function (level) {
var buff = this.options.keepBuffer, var buff = this.options.keepBuffer,
pixelBounds = this._getTiledPixelBounds(this._map.getCenter()), pixelBounds = this._getTiledPixelBounds(this._map.getCenter()),
tileRange = this._pxBoundsToTileRange(pixelBounds), tileRange = this._pxBoundsToTileRange(pixelBounds),
@ -67,7 +67,7 @@ L.TileLayer.include({
var pixelRange = L.bounds( var pixelRange = L.bounds(
tileRange.min.scaleBy(tileSize), tileRange.min.scaleBy(tileSize),
tileRange.max.add([1, 1]).scaleBy(tileSize) // This prevents an off-by-one when checking if tiles are inside tileRange.max.add([1, 1]).scaleBy(tileSize), // This prevents an off-by-one when checking if tiles are inside
), ),
mustRepositionCanvas = false, mustRepositionCanvas = false,
neededSize = pixelRange.max.subtract(pixelRange.min); neededSize = pixelRange.max.subtract(pixelRange.min);
@ -84,14 +84,14 @@ L.TileLayer.include({
var oldSize = { x: level.canvas.width, y: level.canvas.height }; var oldSize = { x: level.canvas.width, y: level.canvas.height };
// console.info('Resizing canvas from ', oldSize, 'to ', neededSize); // console.info('Resizing canvas from ', oldSize, 'to ', neededSize);
var tmpCanvas = L.DomUtil.create("canvas"); var tmpCanvas = L.DomUtil.create('canvas');
tmpCanvas.style.width = (tmpCanvas.width = oldSize.x) + "px"; tmpCanvas.style.width = (tmpCanvas.width = oldSize.x) + 'px';
tmpCanvas.style.height = (tmpCanvas.height = oldSize.y) + "px"; tmpCanvas.style.height = (tmpCanvas.height = oldSize.y) + 'px';
tmpCanvas.getContext("2d").drawImage(level.canvas, 0, 0); tmpCanvas.getContext('2d').drawImage(level.canvas, 0, 0);
// var data = level.ctx.getImageData(0, 0, oldSize.x, oldSize.y); // var data = level.ctx.getImageData(0, 0, oldSize.x, oldSize.y);
level.canvas.style.width = (level.canvas.width = neededSize.x) + "px"; level.canvas.style.width = (level.canvas.width = neededSize.x) + 'px';
level.canvas.style.height = (level.canvas.height = neededSize.y) + "px"; level.canvas.style.height = (level.canvas.height = neededSize.y) + 'px';
level.ctx.drawImage(tmpCanvas, 0, 0); level.ctx.drawImage(tmpCanvas, 0, 0);
// level.ctx.putImageData(data, 0, 0, 0, 0, oldSize.x, oldSize.y); // level.ctx.putImageData(data, 0, 0, 0, 0, oldSize.x, oldSize.y);
} }
@ -109,22 +109,22 @@ L.TileLayer.include({
// this to *replace* the existing pixels when doing a drawImage() call. // this to *replace* the existing pixels when doing a drawImage() call.
// This will also clear the sides, so no clearRect() calls are needed to make room // This will also clear the sides, so no clearRect() calls are needed to make room
// for the new tiles. // for the new tiles.
level.ctx.globalCompositeOperation = "copy"; level.ctx.globalCompositeOperation = 'copy';
level.ctx.drawImage(level.canvas, offset.x, offset.y); level.ctx.drawImage(level.canvas, offset.x, offset.y);
level.ctx.globalCompositeOperation = "source-over"; level.ctx.globalCompositeOperation = 'source-over';
} else { } else {
// Safari clears the canvas when copying from itself :-( // Safari clears the canvas when copying from itself :-(
if (!this._tmpCanvas) { if (!this._tmpCanvas) {
var t = (this._tmpCanvas = L.DomUtil.create("canvas")); var t = (this._tmpCanvas = L.DomUtil.create('canvas'));
t.width = level.canvas.width; t.width = level.canvas.width;
t.height = level.canvas.height; t.height = level.canvas.height;
this._tmpContext = t.getContext("2d"); this._tmpContext = t.getContext('2d');
} }
this._tmpContext.clearRect( this._tmpContext.clearRect(
0, 0,
0, 0,
level.canvas.width, level.canvas.width,
level.canvas.height level.canvas.height,
); );
this._tmpContext.drawImage(level.canvas, 0, 0); this._tmpContext.drawImage(level.canvas, 0, 0);
level.ctx.clearRect(0, 0, level.canvas.width, level.canvas.height); level.ctx.clearRect(0, 0, level.canvas.width, level.canvas.height);
@ -146,13 +146,13 @@ L.TileLayer.include({
this._setCanvasZoomTransform( this._setCanvasZoomTransform(
level, level,
this._map.getCenter(), this._map.getCenter(),
this._map.getZoom() this._map.getZoom(),
); );
} }
}, },
/// set transform/position of canvas, in addition to the transform/position of the individual tile container /// set transform/position of canvas, in addition to the transform/position of the individual tile container
_setZoomTransform: function(level, center, zoom) { _setZoomTransform: function (level, center, zoom) {
L.GridLayer.prototype._setZoomTransform.call(this, level, center, zoom); L.GridLayer.prototype._setZoomTransform.call(this, level, center, zoom);
if (this.options.dumpToCanvas) { if (this.options.dumpToCanvas) {
this._setCanvasZoomTransform(level, center, zoom); this._setCanvasZoomTransform(level, center, zoom);
@ -162,7 +162,7 @@ L.TileLayer.include({
// This will get called twice: // This will get called twice:
// * From _setZoomTransform // * From _setZoomTransform
// * When the canvas has shifted due to a new tile being loaded // * When the canvas has shifted due to a new tile being loaded
_setCanvasZoomTransform: function(level, center, zoom) { _setCanvasZoomTransform: function (level, center, zoom) {
// console.log('_setCanvasZoomTransform', level, center, zoom); // console.log('_setCanvasZoomTransform', level, center, zoom);
if (!level.canvasOrigin) { if (!level.canvasOrigin) {
return; return;
@ -180,7 +180,7 @@ L.TileLayer.include({
} }
}, },
_onOpaqueTile: function(tile) { _onOpaqueTile: function (tile) {
if (!this.options.dumpToCanvas) { if (!this.options.dumpToCanvas) {
return; return;
} }
@ -192,8 +192,8 @@ L.TileLayer.include({
try { try {
this.dumpPixels(tile.coords, tile.el); this.dumpPixels(tile.coords, tile.el);
} catch (ex) { } catch (ex) {
return this.fire("tileerror", { return this.fire('tileerror', {
error: "Could not copy tile pixels: " + ex, error: 'Could not copy tile pixels: ' + ex,
tile: tile, tile: tile,
coods: tile.coords, coods: tile.coords,
}); });
@ -202,7 +202,7 @@ L.TileLayer.include({
// If dumping the pixels was successful, then hide the tile. // If dumping the pixels was successful, then hide the tile.
// Do not remove the tile itself, as it is needed to check if the whole // Do not remove the tile itself, as it is needed to check if the whole
// level (and its canvas) should be removed (via level.el.children.length) // level (and its canvas) should be removed (via level.el.children.length)
tile.el.style.display = "none"; tile.el.style.display = 'none';
}, },
// @section Extension methods // @section Extension methods
@ -214,7 +214,7 @@ L.TileLayer.include({
// like `{x: Number, y: Number, z: Number}`; the image source must have the // like `{x: Number, y: Number, z: Number}`; the image source must have the
// same size as the `tileSize` option for the layer. Has no effect if `dumpToCanvas` // same size as the `tileSize` option for the layer. Has no effect if `dumpToCanvas`
// is `false`. // is `false`.
dumpPixels: function(coords, imageSource) { dumpPixels: function (coords, imageSource) {
var level = this._levels[coords.z], var level = this._levels[coords.z],
tileSize = this.getTileSize(); tileSize = this.getTileSize();
@ -234,7 +234,13 @@ L.TileLayer.include({
.subtract(level.canvasRange.min) .subtract(level.canvasRange.min)
.scaleBy(this.getTileSize()); .scaleBy(this.getTileSize());
level.ctx.drawImage(imageSource, offset.x, offset.y, tileSize.x, tileSize.y); level.ctx.drawImage(
imageSource,
offset.x,
offset.y,
tileSize.x,
tileSize.y,
);
// TODO: Clear the pixels of other levels' canvases where they overlap // TODO: Clear the pixels of other levels' canvases where they overlap
// this newly dumped tile. // this newly dumped tile.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long