Skip to content

Commit 8b37f92

Browse files
committed
tweaks
1 parent e10a727 commit 8b37f92

3 files changed

Lines changed: 55 additions & 26 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "goude-site",
33
"type": "module",
4-
"version": "2.3.5",
4+
"version": "2.3.6",
55
"scripts": {
66
"dev": "astro dev",
77
"build": "astro check && astro build",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Without breaking what works, with minimal line diffs, and giving the whole file back, please take the complete code file provided, apply the required updates directly, and return the entire file in full. Make the smallest possible set of changes. Preserve all existing functionality. Do not refactor, rename, reorder, or restyle code unless strictly required to implement the requested change. Do not introduce new abstractions, indentation changes, or formatting differences beyond what is necessary for correctness. When reporting back what you did tell what you did (not what you did not do).
1+
Without breaking what works, with minimal line diffs, and giving the whole file back, please take the complete code file provided, apply the required updates directly, and return the entire file in full. Make the smallest possible set of changes. Preserve all existing functionality. Do not refactor, rename, reorder, or restyle code unless strictly required to implement the requested change. Do not introduce new abstractions, indentation changes, or formatting differences beyond what is necessary for correctness. When reporting back what you did tell what you did (not what you did not do). So give back the WHOLE file without skipping anything, for easy copying/pasting. Thx.
22

src/components/Header.astro

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,23 @@ const navRight = NAV_ITEMS.filter((item) => item.external);
269269
font-size: 1.1em;
270270
}
271271

272-
/* Crossfade for rotating icons only (no layout changes) */
273-
.nav-action i[data-icon-rotate] {
274-
transition: opacity 0.25s ease;
272+
/* CSS animation for rotating icons */
273+
@keyframes icon-swap {
274+
0% {
275+
opacity: 1;
276+
}
277+
40% {
278+
opacity: 0;
279+
}
280+
60% {
281+
opacity: 0;
282+
}
283+
100% {
284+
opacity: 1;
285+
}
286+
}
287+
.nav-action i[data-icon-rotate].rotating {
288+
animation: icon-swap 0.35s ease forwards;
275289
}
276290

277291
/* Shared selected style */
@@ -628,34 +642,49 @@ const navRight = NAV_ITEMS.filter((item) => item.external);
628642

629643
const pickNextDifferent = (arr, cur) => {
630644
if (arr.length <= 1) return cur;
631-
let next = cur;
632-
let tries = 0;
645+
let next = cur,
646+
tries = 0;
633647
while (next === cur && tries < 5) {
634648
next = arr[Math.floor(Math.random() * arr.length)];
635-
tries += 1;
649+
tries++;
636650
}
637651
return next;
638652
};
639653

640-
const rotateIcons = () => {
641-
document.querySelectorAll("i[data-icon-rotate]").forEach((el) => {
642-
const raw = el.getAttribute("data-icons") || "";
643-
const icons = raw ? raw.split("|").filter(Boolean) : [];
644-
if (icons.length <= 1) return;
645-
646-
const cur = el.className;
647-
const next = pickNextDifferent(icons, cur);
648-
if (next === cur) return;
654+
const INTERVAL = 65536; // ms
655+
const rotIcons = Array.from(
656+
document.querySelectorAll("i[data-icon-rotate]")
657+
);
658+
const perItem = rotIcons.length > 0 ? INTERVAL / rotIcons.length : INTERVAL;
649659

650-
el.style.opacity = "0";
660+
rotIcons.forEach((el, i) => {
661+
const scheduleNext = (delay) => {
651662
window.setTimeout(() => {
652-
el.className = next;
653-
el.style.opacity = "1";
654-
}, 140);
655-
});
656-
};
657-
658-
rotateIcons();
659-
window.setInterval(rotateIcons, 10000);
663+
const raw = el.getAttribute("data-icons") || "";
664+
const list = raw.split("|").filter(Boolean);
665+
if (list.length <= 1) {
666+
scheduleNext(INTERVAL);
667+
return;
668+
}
669+
const cur = Array.from(el.classList)
670+
.filter((c) => c !== "rotating")
671+
.join(" ");
672+
el.classList.add("rotating");
673+
window.setTimeout(() => {
674+
const next = pickNextDifferent(list, cur);
675+
el.className = next + " rotating";
676+
}, 140);
677+
el.addEventListener(
678+
"animationend",
679+
() => {
680+
el.classList.remove("rotating");
681+
scheduleNext(INTERVAL);
682+
},
683+
{ once: true }
684+
);
685+
}, delay);
686+
};
687+
scheduleNext(i * perItem);
688+
});
660689
})();
661690
</script>

0 commit comments

Comments
 (0)