mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-11-15 22:43:13 +01:00
Improve canvas loading
A
This commit is contained in:
parent
0a73912cd7
commit
904fee390b
3 changed files with 58 additions and 10 deletions
|
@ -125,7 +125,7 @@ header {
|
|||
background-color: #555;
|
||||
border-right: 1px #000 solid;
|
||||
border-bottom: 1px #000 solid;
|
||||
z-index: 2000;
|
||||
z-index: 2100;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,16 @@ #loading {
|
|||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
[data-init-done][data-canvas-loading='false'] #loading {
|
||||
display: none
|
||||
}
|
||||
|
||||
[data-init-done] #loading {
|
||||
z-index: 1000;
|
||||
animation: fadeInOut 4s linear 0s 1;
|
||||
}
|
||||
|
||||
#loading > div {
|
||||
|
@ -274,10 +283,25 @@ #loading > div > div:first-child {
|
|||
}
|
||||
|
||||
#loading > div > span {
|
||||
font-family: "DejaVu Sans", Helvetica, sans-serif;
|
||||
font-family: dejavu, Helvetica, sans-serif;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
@keyframes fadeInOut {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
52.5% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spinner {
|
||||
from {
|
||||
transform: rotateZ(0deg);
|
||||
|
@ -609,7 +633,7 @@ .overlay {
|
|||
background-color: rgba(0, 0, 0, .8);
|
||||
display: none;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
#exportWindow {
|
||||
|
@ -657,7 +681,7 @@ #coordsWrapper {
|
|||
position: absolute;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
z-index: 100;
|
||||
z-index: 1100;
|
||||
top: 5px;
|
||||
left: 364px;
|
||||
}
|
||||
|
@ -764,6 +788,11 @@ #timeControls:hover #timeControlsTooltip {
|
|||
display: flex;
|
||||
}
|
||||
|
||||
#zoomControls,
|
||||
#timeControls {
|
||||
z-index: 1100;
|
||||
}
|
||||
|
||||
.slider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
|
@ -786,7 +815,7 @@ #author {
|
|||
border: 1px #000 solid;
|
||||
padding: 3px;
|
||||
font-size: 12px;
|
||||
z-index: 1100;
|
||||
z-index: 2100;
|
||||
min-width: 320px;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
|
@ -1141,7 +1170,7 @@ #donateButton {
|
|||
|
||||
#donateWindow {
|
||||
display: inline-block;
|
||||
z-index: 2000;
|
||||
z-index: 2100;
|
||||
max-width: 400px;
|
||||
background-color: #444;
|
||||
border: 1px #000 solid;
|
||||
|
|
|
@ -186,8 +186,6 @@ async function init(){
|
|||
initView();
|
||||
}
|
||||
|
||||
document.getElementById("loading").style.display = "none";
|
||||
|
||||
document.getElementById("zoomInButton").addEventListener("click", function(e){
|
||||
|
||||
/*if(zoomAnimationFrame){
|
||||
|
@ -496,4 +494,6 @@ async function init(){
|
|||
applyView();
|
||||
});
|
||||
|
||||
document.body.dataset.initDone = ''
|
||||
|
||||
}
|
||||
|
|
|
@ -96,6 +96,10 @@ const timeConfig = [
|
|||
let slider = document.getElementById("timeControlsSlider");
|
||||
let tooltip = document.getElementById("timeControlsTooltip")
|
||||
let image = document.getElementById("image");
|
||||
let abortController = new AbortController()
|
||||
let currentUpdateIndex = 0
|
||||
let loadingTimeout = setInterval(null, 0)
|
||||
let updateTimeout = setInterval(null, 0)
|
||||
|
||||
let timeCallback = (a) => {};
|
||||
let atlasBackup = [];
|
||||
|
@ -106,14 +110,28 @@ slider.value = timeConfig.length;
|
|||
updateTime(slider.value)
|
||||
|
||||
slider.addEventListener("input", (event) => {
|
||||
clearTimeout(updateTimeout)
|
||||
updateTimeout = setInterval(() => {
|
||||
updateTime(parseInt(event.target.value))
|
||||
}, 100)
|
||||
})
|
||||
|
||||
async function updateTime(index) {
|
||||
document.body.dataset.canvasLoading = true
|
||||
abortController.abort()
|
||||
abortController = new AbortController()
|
||||
currentUpdateIndex++
|
||||
let myUpdateIndex = currentUpdateIndex
|
||||
let configObject = timeConfig[index-1];
|
||||
if (!configObject.image) {
|
||||
console.log("fetching");
|
||||
let fetchResult = await fetch(configObject.url);
|
||||
let fetchResult = await fetch(configObject.url, {
|
||||
signal: abortController.signal
|
||||
});
|
||||
if (currentUpdateIndex !== myUpdateIndex) {
|
||||
hideLoading()
|
||||
return
|
||||
}
|
||||
let imageBlob = await fetchResult.blob();
|
||||
configObject.image = URL.createObjectURL(imageBlob);
|
||||
}
|
||||
|
@ -128,6 +146,7 @@ async function updateTime(index) {
|
|||
if (typeof configObject.timestamp === "number") tooltip.querySelector('p').textContent = new Date(configObject.timestamp*1000).toUTCString()
|
||||
else tooltip.querySelector('p').textContent = configObject.timestamp
|
||||
tooltip.style.left = (((slider.offsetWidth)*(slider.value-1)/(slider.max-1)) - tooltip.offsetWidth/2) + "px"
|
||||
document.body.dataset.canvasLoading = false
|
||||
}
|
||||
|
||||
tooltip.parentElement.addEventListener('mouseenter', () => tooltip.style.left = (((slider.offsetWidth)*(slider.value-1)/(slider.max-1)) - tooltip.offsetWidth/2) + "px"
|
||||
|
|
Loading…
Reference in a new issue