Avoid recreating tiles from scratch when refreshing Pl3xmap
This commit is contained in:
parent
f316c0dd50
commit
552b289bb9
@ -43,15 +43,15 @@ export default defineComponent({
|
|||||||
const store = useStore(),
|
const store = useStore(),
|
||||||
active = computed(() => props.map === store.state.currentMap);
|
active = computed(() => props.map === store.state.currentMap);
|
||||||
|
|
||||||
let redrawTimeout = 0,
|
let refreshTimeout = 0,
|
||||||
layer: LiveAtlasTileLayer;
|
layer: LiveAtlasTileLayer;
|
||||||
|
|
||||||
const redraw = () => {
|
const refresh = () => {
|
||||||
if(active.value) {
|
if(active.value) {
|
||||||
layer._update();
|
layer.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval);
|
refreshTimeout = setTimeout(refresh, props.map.tileUpdateInterval);
|
||||||
};
|
};
|
||||||
|
|
||||||
if(store.state.currentServer?.type === 'dynmap') {
|
if(store.state.currentServer?.type === 'dynmap') {
|
||||||
@ -81,14 +81,14 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(props.map.tileUpdateInterval) {
|
if(props.map.tileUpdateInterval) {
|
||||||
redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval);
|
refreshTimeout = setTimeout(refresh, props.map.tileUpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
disableLayer();
|
disableLayer();
|
||||||
|
|
||||||
if(redrawTimeout) {
|
if(refreshTimeout) {
|
||||||
clearTimeout(redrawTimeout);
|
clearTimeout(refreshTimeout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -144,6 +144,22 @@ export abstract class LiveAtlasTileLayer extends TileLayer {
|
|||||||
this.fetchTile(tile);
|
this.fetchTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
for (const i in this._tiles) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(this._tiles, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tile = this._tiles[i] as LiveAtlasTile;
|
||||||
|
|
||||||
|
if(tile.loaded) {
|
||||||
|
this.loadQueue.push(tile.el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tickLoadQueue();
|
||||||
|
}
|
||||||
|
|
||||||
_abortLoading() {
|
_abortLoading() {
|
||||||
let tile;
|
let tile;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user