-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
49 lines (42 loc) · 1.03 KB
/
script.js
File metadata and controls
49 lines (42 loc) · 1.03 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
39
40
41
42
43
44
45
46
47
48
49
particlesJS.load('particles-js', 'particles-config.json', function() {
console.log('Particles.js is loaded');
});
const typed = new Typed(".typing", {
strings: ["Software Developer", "Pythonista", "Web Developer"],
loop: true,
typeSpeed: 80,
backSpeed: 40,
});
const themes = [
"#9affe0",
"#ff9a9a",
"#f5ff9a",
"#9aadff",
"#ffd270",
"#adff7b",
"#6bfaff",
"#56F7DD",
"#F770F3",
]
const root = document.querySelector(":root");
const themeToggle = document.querySelector("#name");
let currentTheme = 0;
const changeTheme = () => {
currentTheme++;
if (currentTheme == themes.length) {
currentTheme = 0;
}
root.style.setProperty("--main-accent", themes[currentTheme]);
console.log("Accent set to: " + themes[currentTheme]);
};
themeToggle.addEventListener("click", () => {
changeTheme();
});
let scrolling = false;
window.addEventListener("scroll", () => {
if (!scrolling) {
changeTheme();
scrolling = true;
setTimeout(() => (scrolling = false), 5000);
}
});