Skip to content

Commit 38fe7dc

Browse files
committed
简化与优化加载动画逻辑,新增退出动画关键帧与分阶段动画效果,提升用户交互体验与动画细节表现力。
1 parent 7df8856 commit 38fe7dc

File tree

2 files changed

+153
-13
lines changed

2 files changed

+153
-13
lines changed

composeApp/src/wasmJsMain/resources/loading.css

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,99 @@
359359
margin-right: 5px;
360360
}
361361

362+
/* Simplified Exit Animation Keyframes - Subtle and Elegant */
363+
@keyframes exitFade {
364+
0% {
365+
opacity: 1;
366+
transform: scale(1);
367+
}
368+
100% {
369+
opacity: 0;
370+
transform: scale(0.95);
371+
}
372+
}
373+
374+
@keyframes exitSlideUp {
375+
0% {
376+
opacity: 1;
377+
transform: translateY(0);
378+
}
379+
100% {
380+
opacity: 0;
381+
transform: translateY(-30px);
382+
}
383+
}
384+
385+
@keyframes exitSlideDown {
386+
0% {
387+
opacity: 1;
388+
transform: translateY(0);
389+
}
390+
100% {
391+
opacity: 0;
392+
transform: translateY(30px);
393+
}
394+
}
395+
396+
@keyframes exitScale {
397+
0% {
398+
opacity: 1;
399+
transform: scale(1);
400+
}
401+
100% {
402+
opacity: 0;
403+
transform: scale(0.8);
404+
}
405+
}
406+
407+
408+
/* Simplified Exit Animation Classes - Subtle and Elegant */
409+
.loading-container.exiting {
410+
animation: exitFade 0.5s ease-out forwards;
411+
}
412+
413+
.loader.exiting {
414+
animation: exitScale 0.4s ease-out forwards;
415+
}
416+
417+
.progress-container.exiting {
418+
animation: exitSlideDown 0.3s ease-out forwards;
419+
}
420+
421+
.progress-text.exiting {
422+
animation: exitSlideUp 0.3s ease-out forwards;
423+
}
424+
425+
.code-animation.exiting {
426+
animation: exitFade 0.3s ease-out forwards;
427+
}
428+
429+
.tags.exiting,
430+
.tag.exiting {
431+
animation: exitFade 0.4s ease-out forwards;
432+
}
433+
434+
.info-text.exiting {
435+
animation: exitSlideUp 0.3s ease-out forwards;
436+
}
437+
438+
.pulse.exiting {
439+
animation: exitScale 0.4s ease-out forwards;
440+
}
441+
442+
.ripple.exiting {
443+
animation: exitScale 0.4s ease-out forwards;
444+
}
445+
446+
.float-particle.exiting,
447+
.orbit-particle.exiting {
448+
animation: exitFade 0.5s ease-out forwards;
449+
}
450+
451+
.core.exiting {
452+
animation: exitScale 0.4s ease-out forwards;
453+
}
454+
362455
/* Compose App Container */
363456
#codegen-root {
364457
width: 100vw;

composeApp/src/wasmJsMain/resources/loading.js

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,70 @@ window.notifyFontLoadingComplete = function() {
182182
progressText.textContent = '字体加载完成!';
183183
}
184184

185-
// Optimized fade-out with better performance
185+
// Enhanced exit animation sequence
186186
if (loadingContainer) {
187-
requestAnimationFrame(() => {
188-
loadingContainer.style.transition = 'opacity 0.5s ease-out';
189-
loadingContainer.style.opacity = '0';
190-
191-
setTimeout(() => {
192-
loadingContainer.style.display = 'none';
193-
loadingContainer.remove();
194-
195-
// Clear references for garbage collection
196-
window.loadingIntervals = null;
197-
}, 500);
198-
});
187+
performExitAnimation(loadingContainer);
199188
}
200189
};
201190

191+
// Enhanced exit animation function with modern tech effects
192+
function performExitAnimation(loadingContainer) {
193+
console.log("Starting enhanced tech-style exit animation");
194+
195+
requestAnimationFrame(() => {
196+
// Get all animated elements including new tech elements
197+
const loader = loadingContainer.querySelector('.loader');
198+
const progressContainer = loadingContainer.querySelector('.progress-container');
199+
const progressText = loadingContainer.querySelector('.progress-text');
200+
const codeAnimation = loadingContainer.querySelector('.code-animation');
201+
const tags = loadingContainer.querySelector('.tags');
202+
const tagElements = loadingContainer.querySelectorAll('.tag');
203+
const infoText = loadingContainer.querySelector('.info-text');
204+
const pulse = loadingContainer.querySelector('.pulse');
205+
const core = loadingContainer.querySelector('.core');
206+
const ripples = loadingContainer.querySelectorAll('.ripple');
207+
const orbitParticles = loadingContainer.querySelectorAll('.orbit-particle');
208+
const particles = loadingContainer.querySelectorAll('.float-particle');
209+
210+
// Simple staggered exit animations - elegant and restrained
211+
setTimeout(() => {
212+
// Stage 1: Core elements (100ms delay)
213+
if (core) core.classList.add('exiting');
214+
if (pulse) pulse.classList.add('exiting');
215+
ripples.forEach(ripple => ripple.classList.add('exiting'));
216+
if (loader) loader.classList.add('exiting');
217+
}, 100);
218+
219+
setTimeout(() => {
220+
// Stage 2: UI elements (200ms total delay)
221+
if (progressContainer) progressContainer.classList.add('exiting');
222+
if (progressText) progressText.classList.add('exiting');
223+
if (codeAnimation) codeAnimation.classList.add('exiting');
224+
if (tags) tags.classList.add('exiting');
225+
tagElements.forEach(tag => tag.classList.add('exiting'));
226+
if (infoText) infoText.classList.add('exiting');
227+
}, 200);
228+
229+
setTimeout(() => {
230+
// Stage 3: Particles and final container (400ms total delay)
231+
particles.forEach(particle => particle.classList.add('exiting'));
232+
orbitParticles.forEach(particle => particle.classList.add('exiting'));
233+
loadingContainer.classList.add('exiting');
234+
}, 400);
235+
236+
// Clean and efficient cleanup
237+
setTimeout(() => {
238+
loadingContainer.style.display = 'none';
239+
loadingContainer.remove();
240+
241+
// Clear references for garbage collection
242+
window.loadingIntervals = null;
243+
244+
console.log("Loading animation completed - subtle and elegant");
245+
}, 800); // Reduced duration: 800ms
246+
});
247+
}
248+
202249
// Initialize when DOM is ready
203250
if (document.readyState === 'loading') {
204251
document.addEventListener('DOMContentLoaded', initializeLoadingScreen);

0 commit comments

Comments
 (0)