Skip to content

Commit 4d393ec

Browse files
committed
fix: Multiple registration events lead to incorrect click events
1 parent 18032fc commit 4d393ec

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/components/Navbar.astro

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,29 @@ function switchTheme() {
7474
function loadButtonScript() {
7575
let switchBtn = document.getElementById("scheme-switch");
7676
if (switchBtn) {
77-
switchBtn.addEventListener("click", function () {
77+
switchBtn.onclick = function () {
7878
switchTheme()
79-
});
79+
};
8080
}
8181

8282
let settingBtn = document.getElementById("display-settings-switch");
8383
if (settingBtn) {
84-
settingBtn.addEventListener("click", function () {
84+
settingBtn.onclick = function () {
8585
let settingPanel = document.getElementById("display-setting");
8686
if (settingPanel) {
8787
settingPanel.classList.toggle("float-panel-closed");
8888
}
89-
});
89+
};
9090
}
9191

9292
let menuBtn = document.getElementById("nav-menu-switch");
9393
if (menuBtn) {
94-
menuBtn.addEventListener("click", function () {
94+
menuBtn.onclick = function () {
9595
let menuPanel = document.getElementById("nav-menu-panel");
9696
if (menuPanel) {
9797
menuPanel.classList.toggle("float-panel-closed");
9898
}
99-
});
99+
};
100100
}
101101
}
102102

0 commit comments

Comments
 (0)