Skip to content

Commit 407e6a2

Browse files
committed
add: theme toggle spam protection
1 parent 1535bd6 commit 407e6a2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/lib/components/ThemeToggle.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,35 @@
2424
if (!theme.isDark) {
2525
moonButton.addEventListener("animationend", listener);
2626
moonButton.classList.add("roll-out");
27+
moonButton.classList.add("pointer-events-none");
28+
sunButton.classList.add("pointer-events-none");
2729
2830
function listener(event: AnimationEvent) {
2931
if (event.type === "animationend") {
3032
moonButton.classList.add("hidden");
3133
moonButton.classList.remove("roll-out");
3234
sunButton.classList.remove("hidden");
3335
sunButton.classList.add("roll-in");
36+
moonButton.classList.remove("pointer-events-none");
37+
sunButton.classList.remove("pointer-events-none");
3438
}
3539
3640
moonButton.removeEventListener("animationend", listener);
3741
}
3842
} else {
3943
sunButton.addEventListener("animationend", listener);
4044
sunButton.classList.add("roll-out");
45+
sunButton.classList.add("pointer-events-none");
46+
moonButton.classList.add("pointer-events-none");
4147
4248
function listener(event: AnimationEvent) {
4349
if (event.type === "animationend") {
4450
sunButton.classList.add("hidden");
4551
sunButton.classList.remove("roll-out");
4652
moonButton.classList.remove("hidden");
4753
moonButton.classList.add("roll-in");
54+
moonButton.classList.remove("pointer-events-none");
55+
sunButton.classList.remove("pointer-events-none");
4856
}
4957
5058
sunButton.removeEventListener("animationend", listener);

0 commit comments

Comments
 (0)