优化动画

This commit is contained in:
CN-JS-HuiBai
2026-04-06 02:23:11 +08:00
parent e4b97be54e
commit 217510c07d
2 changed files with 48 additions and 18 deletions

View File

@@ -1992,14 +1992,18 @@ input:checked+.slider:before {
width: 95vw !important; width: 95vw !important;
height: 90vh !important; height: 90vh !important;
z-index: 9999; z-index: 9999;
transform: none !important; /* Remove translate to avoid coordinate issues */ box-shadow: 0 0 80px rgba(0, 0, 0, 0.8), 0 0 0 100vh rgba(0, 0, 0, 0.65);
transition: none !important; /* Avoid transition conflicts during state jump */
box-shadow: 0 0 100px rgba(0, 0, 0, 0.9), 0 0 0 100vh rgba(0, 0, 0, 0.7);
backdrop-filter: blur(20px); backdrop-filter: blur(20px);
margin: 0 !important; margin: 0 !important;
display: flex !important; display: flex !important;
flex-direction: column; flex-direction: column;
border-color: var(--accent-indigo); border-color: var(--accent-indigo);
animation: globeExpandIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
/* Collapse animation (plays while .expanded is still active to keep fixed positioning) */
.globe-card.expanded.globe-collapsing {
animation: globeCollapseOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
} }
/* Ensure children are visible */ /* Ensure children are visible */
@@ -2007,14 +2011,25 @@ input:checked+.slider:before {
opacity: 1 !important; opacity: 1 !important;
} }
@keyframes globeExpand { @keyframes globeExpandIn {
from { from {
opacity: 0; opacity: 0;
transform: translate(-50%, -45%) scale(0.95); transform: scale(0.82);
} }
to { to {
opacity: 1; opacity: 1;
transform: translate(-50%, -50%) scale(1); transform: scale(1);
}
}
@keyframes globeCollapseOut {
from {
opacity: 1;
transform: scale(1);
}
to {
opacity: 0;
transform: scale(0.82);
} }
} }

View File

@@ -208,15 +208,34 @@
} }
// Globe expansion // Globe expansion
function expandGlobe() {
if (dom.globeCard.classList.contains('expanded')) return;
dom.globeCard.classList.add('expanded');
dom.btnExpandGlobe.classList.add('active');
dom.globeCard.addEventListener('animationend', function onExpand() {
dom.globeCard.removeEventListener('animationend', onExpand);
if (myMap2D) myMap2D.resize();
});
}
function collapseGlobe() {
if (!dom.globeCard.classList.contains('expanded')) return;
if (dom.globeCard.classList.contains('globe-collapsing')) return;
dom.globeCard.classList.add('globe-collapsing');
dom.globeCard.addEventListener('animationend', function onCollapse() {
dom.globeCard.removeEventListener('animationend', onCollapse);
dom.globeCard.classList.remove('expanded', 'globe-collapsing');
dom.btnExpandGlobe.classList.remove('active');
if (myMap2D) requestAnimationFrame(() => myMap2D.resize());
});
}
if (dom.btnExpandGlobe) { if (dom.btnExpandGlobe) {
dom.btnExpandGlobe.addEventListener('click', () => { dom.btnExpandGlobe.addEventListener('click', () => {
dom.globeCard.classList.toggle('expanded'); if (dom.globeCard.classList.contains('expanded')) {
dom.btnExpandGlobe.classList.toggle('active'); collapseGlobe();
if (myMap2D) { } else {
// Single deferred resize after the DOM has applied the new layout expandGlobe();
requestAnimationFrame(() => {
myMap2D.resize();
});
} }
}); });
} }
@@ -227,11 +246,7 @@
closeSettings(); closeSettings();
closeLoginModal(); closeLoginModal();
closeServerDetail(); closeServerDetail();
if (dom.globeCard && dom.globeCard.classList.contains('expanded')) { collapseGlobe();
dom.globeCard.classList.remove('expanded');
dom.btnExpandGlobe.classList.remove('active');
if (myMap2D) requestAnimationFrame(() => myMap2D.resize());
}
} }
}); });