-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (33 loc) · 1.18 KB
/
Copy pathscript.js
File metadata and controls
38 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
document.addEventListener("DOMContentLoaded", function () {
const header = document.querySelector("header");
const buttons = document.querySelectorAll("button");
const fonts = ["Apfel Grotesk", "Zara", "Gothique"];
const defaultFont = "Arial";
let fontIndex = 0;
let intervalId;
function cycleFonts(element) {
return setInterval(() => {
element.style.fontFamily = fonts[fontIndex];
fontIndex = (fontIndex + 1) % fonts.length;
}, 250);
}
header.addEventListener("mouseenter", () => {
intervalId = cycleFonts(header);
});
header.addEventListener("mouseleave", () => {
clearInterval(intervalId);
fontIndex = 0;
header.style.fontFamily = defaultFont; // Reset to default font
});
buttons.forEach(button => {
let buttonIntervalId;
button.addEventListener("mouseenter", () => {
buttonIntervalId = cycleFonts(button);
});
button.addEventListener("mouseleave", () => {
clearInterval(buttonIntervalId);
fontIndex = 0;
button.style.fontFamily = defaultFont; // Reset to default font
});
});
});