-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
133 lines (133 loc) · 4.43 KB
/
main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var audio = document.getElementById("audioPlayer"),
loader = document.getElementById("preloader");
function settingtoggle() {
document
.getElementById("setting-container")
.classList.toggle("settingactivate"),
document
.getElementById("visualmodetogglebuttoncontainer")
.classList.toggle("visualmodeshow"),
document
.getElementById("soundtogglebuttoncontainer")
.classList.toggle("soundmodeshow");
}
function playpause() {
!1 == document.getElementById("switchforsound").checked
? audio.pause()
: audio.play();
}
function visualmode() {
document.body.classList.toggle("light-mode"),
document.querySelectorAll(".needtobeinvert").forEach(function (e) {
e.classList.toggle("invertapplied");
});
}
window.addEventListener("load", function () {
(loader.style.display = "none"),
document.querySelector(".hey").classList.add("popup");
});
let emptyArea = document.getElementById("emptyarea"),
mobileTogglemenu = document.getElementById("mobiletogglemenu");
function hamburgerMenu() {
document.body.classList.toggle("stopscrolling"),
document
.getElementById("mobiletogglemenu")
.classList.toggle("show-toggle-menu"),
document
.getElementById("burger-bar1")
.classList.toggle("hamburger-animation1"),
document
.getElementById("burger-bar2")
.classList.toggle("hamburger-animation2"),
document
.getElementById("burger-bar3")
.classList.toggle("hamburger-animation3");
}
function hidemenubyli() {
document.body.classList.toggle("stopscrolling"),
document
.getElementById("mobiletogglemenu")
.classList.remove("show-toggle-menu"),
document
.getElementById("burger-bar1")
.classList.remove("hamburger-animation1"),
document
.getElementById("burger-bar2")
.classList.remove("hamburger-animation2"),
document
.getElementById("burger-bar3")
.classList.remove("hamburger-animation3");
}
const sections = document.querySelectorAll("section"),
navLi = document.querySelectorAll(".navbar .navbar-tabs .navbar-tabs-ul li"),
mobilenavLi = document.querySelectorAll(
".mobiletogglemenu .mobile-navbar-tabs-ul li"
);
window.addEventListener("scroll", () => {
let e = "";
sections.forEach((t) => {
let o = t.offsetTop;
t.clientHeight, pageYOffset >= o - 200 && (e = t.getAttribute("id"));
}),
mobilenavLi.forEach((t) => {
t.classList.remove("activeThismobiletab"),
t.classList.contains(e) && t.classList.add("activeThismobiletab");
}),
navLi.forEach((t) => {
t.classList.remove("activeThistab"),
t.classList.contains(e) && t.classList.add("activeThistab");
});
}),
console.log(
"%c Designed and Developed by Daniel ",
"background-image: linear-gradient(90deg,#8000ff,#6bc5f8); color: white;font-weight:900;font-size:1rem; padding:20px;"
);
let mybutton = document.getElementById("backtotopbutton");
function scrollFunction() {
document.body.scrollTop > 400 || document.documentElement.scrollTop > 400
? (mybutton.style.display = "block")
: (mybutton.style.display = "none");
}
function scrolltoTopfunction() {
(document.body.scrollTop = 0), (document.documentElement.scrollTop = 0);
}
(window.onscroll = function () {
scrollFunction();
}),
document.addEventListener(
"contextmenu",
function (e) {
"IMG" === e.target.nodeName && e.preventDefault();
},
!1
);
let Pupils = document.getElementsByClassName("footer-pupil"),
pupilsArr = Array.from(Pupils),
pupilStartPoint = -10,
pupilRangeX = 20,
pupilRangeY = 15,
mouseXStartPoint = 0,
mouseXEndPoint = window.innerWidth,
currentXPosition = 0,
fracXValue = 0,
mouseYEndPoint = window.innerHeight,
currentYPosition = 0,
fracYValue = 0,
mouseXRange = mouseXEndPoint - mouseXStartPoint;
const mouseMove = (e) => {
(fracXValue =
(currentXPosition = e.clientX - mouseXStartPoint) / mouseXRange),
(fracYValue = (currentYPosition = e.clientY) / mouseYEndPoint);
let t = pupilStartPoint + fracXValue * pupilRangeX,
o = pupilStartPoint + fracYValue * pupilRangeY;
pupilsArr.forEach((e) => {
e.style.transform = `translate(${t}px, ${o}px)`;
});
},
windowResize = (e) => {
(mouseXEndPoint = window.innerWidth),
(mouseYEndPoint = window.innerHeight),
(mouseXRange = mouseXEndPoint - mouseXStartPoint);
};
window.addEventListener("mousemove", mouseMove),
window.addEventListener("resize", windowResize);