new theme changing animation

This commit is contained in:
iTrooz_ 2021-11-19 09:18:00 +01:00
parent 097f8b3c6c
commit 7f17d6fb88
No known key found for this signature in database
GPG Key ID: 9F6DBA12596D5703

View File

@ -1,17 +1,16 @@
function setTransition(div, n){ function setTransition(div, n){
div.style.filter = "blur("+n+"px)" // div.style.filter = "blur("+n+"px)";
div.style.opacity = n/100;
} }
var fading = false var fading = false;
function switchTheme(){ function switchTheme(){
if(fading)return; if(fading)return;
fading = true; fading = true;
let LOOP_TIMES = 100; for(let i=0;i<=100;++i){
setTimeout(() => {setTransition(div, 100-i)}, i*5);
for(let i=0;i<=LOOP_TIMES;++i){
setTimeout(() => {setTransition(div, i*2)}, i*5);
} }
let div = document.getElementsByTagName("body")[0]; let div = document.getElementsByTagName("body")[0];
@ -24,12 +23,12 @@ function switchTheme(){
setTheme("today"); setTheme("today");
} }
for(let i=0;i<=LOOP_TIMES;++i){ for(let i=0;i<=100;++i){
setTimeout(() => {setTransition(div, (LOOP_TIMES-i)*2)}, i*5); setTimeout(() => {setTransition(div, i)}, i*5);
} }
setTimeout(()=>fading=false, LOOP_TIMES*10) setTimeout(()=>fading=false, 100*5)
}, LOOP_TIMES*5) }, 100*5)
} }
@ -49,4 +48,4 @@ if(document.cookie==""){
}else{ }else{
console.log(document.cookie) console.log(document.cookie)
setTheme(document.cookie); // I know, we aren't supposed to store cookies like that setTheme(document.cookie); // I know, we aren't supposed to store cookies like that
} }