From eee7e729922e41ce653e26e34f5386c5ea5893bc Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:17:46 -0700 Subject: [PATCH] Fix the loading screen when `lib.init.layout`. --- game/game.js | 18 ++++++------------ layout/default/layout.css | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/game/game.js b/game/game.js index 32d3fed23..ea859db0c 100644 --- a/game/game.js +++ b/game/game.js @@ -11184,10 +11184,10 @@ } }, layout:function(layout,nosave){ - const previousTransitionDuration=document.documentElement.style.transitionDuration; - document.documentElement.style.transitionDuration='1s'; - const previousFilter=document.documentElement.style.filter,previousWebkitFilter=document.documentElement.style.webkitFilter; - document.documentElement.style.filter=document.documentElement.style.webkitFilter='brightness(0)'; + const loadingScreen=ui.create.div('.loading-screen',document.body),loadingScreenStyle=loadingScreen.style; + loadingScreenStyle.animationDuration='1s'; + loadingScreenStyle.animationFillMode='forwards'; + loadingScreenStyle.animationName='opacity-0-1'; if(layout=='default') layout='mobile'; if(!nosave) game.saveConfig('layout',layout); game.layout=layout; @@ -11298,14 +11298,8 @@ return new Promise(resolve=>setTimeout(resolve,500)); }).then(()=>{ ui.updatec(); - if(previousFilter) document.documentElement.style.filter=previousFilter; - else document.documentElement.style.removeProperty('filter'); - if(previousWebkitFilter) document.documentElement.style.webkitFilter=previousWebkitFilter; - else document.documentElement.style.removeProperty('-webkit-filter'); - return new Promise(resolve=>setTimeout(resolve,1000)); - }).then(()=>{ - if(previousTransitionDuration) document.documentElement.style.transitionDuration=previousTransitionDuration; - else document.documentElement.style.removeProperty('transition-duration'); + loadingScreenStyle.animationName='opacity-1-0'; + loadingScreen.addEventListener('animationend',animationEvent=>animationEvent.target.remove()); }); }, background:function(){ diff --git a/layout/default/layout.css b/layout/default/layout.css index d0ddebad6..65b5ea108 100644 --- a/layout/default/layout.css +++ b/layout/default/layout.css @@ -5041,6 +5041,13 @@ div[data-decoration="bronze"]::after{ border-radius: 16px; } +.loading-screen { + background-color: black; + height: 100%; + width: 100%; + z-index: 31415926; +} + /*--------动画--------*/ @keyframes shadow_thunder { 0% { @@ -5542,6 +5549,24 @@ div[data-decoration="bronze"]::after{ background-position: left center; } } +@keyframes opacity-0-1 { + from { + opacity: 0; + } + + to { + opacity: 1; + } +} +@keyframes opacity-1-0 { + from { + opacity: 1; + } + + to { + opacity: 0; + } +} /*--------其它--------*/ ::-webkit-scrollbar { display: none;