-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (39 loc) · 1.23 KB
/
index.js
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
window.onload = function() {
document.getElementById("funbutton").onclick = function() {mushroomMode()};
}
// When the user scrolls the page, execute myFunction
window.onscroll = function() {stickyFunction()};
// Get the navbar
var navbar = document.getElementById("navbar");
// Get the offset position of the navbar
var sticky = navbar.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function stickyFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
var colorMarker = 0;
var colorInterval;
function mushroomMode() {
if (colorMarker <= 0) {
colorMarker = 1;
colorInterval = setInterval(changeColor, 10);
}
else {
clearInterval(colorInterval);
colorMarker = 0;
document.body.style.background = "white";
}
}
function changeColor() {
var x, y, z;
colorMarker++;
x = Math.min(colorMarker % 256, 256-colorMarker%256);
y = Math.min ( (colorMarker + 80) % 256, 256-(colorMarker + 80) % 256);
z = Math.min ( (colorMarker + 160) % 256, 256-(colorMarker + 160) % 256);
var color = "rgb(" + x + "," + y + "," + z + ")";
document.body.style.background = color;
}