-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (60 loc) · 2.46 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
let h = window.innerHeight;
alert("Use keyboard to scroll for smooth effect rigtnow. I'm working on smooth scrolling through mouse too :)")
var book7 = document.getElementById('book7');
var book6 = document.getElementById('book6');
var book5 = document.getElementById('book5');
var book4 = document.getElementById('book4');
var book3 = document.getElementById('book3');
var book2 = document.getElementById('book2');
var book1 = document.getElementById('book1');
var changeBg = document.getElementsByClassName("main");
changeBg[0].style.backgroundColor = "#ff608c";
window.onscroll = function (event) {
var scroll = window.scrollY;
if (scroll < h - (h / 3)) {
changeBg[0].style.backgroundColor = "#ff608c";
book7.classList.add("bold");
book6.classList.remove("bold");
} else if (scroll >= h - (h / 3) && scroll < 2 * h - (h / 3)) {
changeBg[0].style.background = " white";
book7.classList.remove("bold");
book6.classList.add("bold");
book5.classList.remove("bold");
} else if (scroll >= 2 * h - (h / 3) && scroll < 3 * h - (h / 3)) {
changeBg[0].style.backgroundColor = '#00c1b5';
book6.classList.remove("bold");
book5.classList.add("bold");
book4.classList.remove("bold");
} else if (scroll >= 3 * h - (h / 3) && scroll < 4 * h - (h / 3)) {
changeBg[0].style.backgroundColor = '#ff651a';
book5.classList.remove("bold");
book4.classList.add("bold");
book3.classList.remove("bold");
} else if (scroll >= 4 * h - (h / 3) && scroll < 5 * h - (h / 3)) {
changeBg[0].style.backgroundColor = '#ffbe00';
book4.classList.remove("bold");
book3.classList.add("bold");
book2.classList.remove("bold");
} else if (scroll >= 5 * h - (h / 3) && scroll < 6 * h - (h / 3)) {
changeBg[0].style.backgroundColor = '#1d3fbb';
book3.classList.remove("bold");
book2.classList.add("bold");
book1.classList.remove("bold");
} else {
changeBg[0].style.backgroundColor = '#e30512';
book2.classList.remove("bold");
book1.classList.add("bold");
}
}
window.addEventListener("wheel", (event) => {
console.log(event);
})
var wheelDistance = function (evt) {
// wheelDelta indicates how
// Far the wheel is turned
var w = evt.wheelDelta;
// Returning normalized value
return w / 120;
}
// Adding event listener for some element
somEl.addEventListener("mousewheel", wheelDistance);