-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
174 lines (154 loc) · 3.96 KB
/
script.js
File metadata and controls
174 lines (154 loc) · 3.96 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
function loader() {
let t1 = gsap.timeline();
t1.to("#yellow1", {
top: "-100%",
delay: 0.2,
duration: 0.4,
ease: "expo.out",
});
t1.from(
"#yellow2",
{
top: "100%",
delay: 0.3,
duration: 0.5,
ease: "expo.out",
},
"a"
);
t1.to(
"#page1 h1",
{
delay: 0.5,
duration: 0.5,
color: "black",
},
"a"
);
t1.to(
"nav svg path",
{
delay: 0.7,
duration: 0.4,
fill: "black",
},
"a"
);
t1.to(
"nav #Rnav ul li",
{
delay: 0.7,
duration: 0.4,
color: "black",
stroke: "black",
},
"a"
);
t1.to(
"nav #Rnav ul li g",
{
delay: 0.7,
duration: 0.4,
stroke: "black",
},
"a"
);
t1.to("video", {
opacity: 0,
duration: 0.01,
ease: "expo.out",
});
t1.to("#yellow2", {
opacity: 0,
duration: 0.1,
ease: "expo.out",
});
}
loader();
let imageSlider = () => {
let dataElem = document.querySelectorAll("#data");
let page2 = document.querySelector("#page2");
let nav_bar = document.querySelectorAll("#Rnav li");
dataElem.forEach((ele) => {
ele.addEventListener("mouseenter", function () {
let bgImg = ele.getAttribute("data-img");
page2.style.backgroundImage = `url(${bgImg})`;
// when mouse enter in the text the nav bar text color change to black
for (let i = 0; i < nav_bar.length; i++) {
nav_bar[i].style.color = "black";
}
});
ele.addEventListener("mouseleave", function () {
page2.style.backgroundImage = "none";
for (let i = 0; i < nav_bar.length; i++) {
nav_bar[i].style.color = "white";
}
});
});
};
imageSlider();
let scrollerToTop = () => {
let icon = document.querySelector("footer #top");
console.log(icon);
icon.addEventListener("click", function () {
scroll.scrollTo(0);
});
};
scrollerToTop();
const scroll = new LocomotiveScroll({
el: document.querySelector("#main"),
smooth: true,
lerp: 0.1,
});
//on scroll and click to menu icon the nav bar elements changes
let nav_BarChanges = () => {
let menuIcon = document.querySelector("#Rnav li svg");
let nav_bar = document.querySelectorAll("#Rnav li");
let logo = document.querySelector("#Lnav path");
let menuSvg = document.querySelector("#Rnav li svg g");
//On Scroll nav bar changes
scroll.on("scroll", (e) => {
if (e.scroll.y > 100 && e.scroll.y < 220) {
// when scroll the plus icon rotates
menuIcon.style.transform = "rotate(90deg)";
// when scroll the projects,about , studies gets small
nav_bar[1].style.opacity = "0";
nav_bar[2].style.opacity = "0";
nav_bar[0].style.transform = `translateX(250px)`;
}
//Every thing that changes after coming back they all get normal
else if (e.scroll.y <= 100) {
menuIcon.style.transform = "rotate(45deg)";
nav_bar[1].style.opacity = "1";
nav_bar[2].style.opacity = "1";
nav_bar[0].style.transform = `translateX(0px)`;
}
// Change the color of nav bar logo and text when enter in the black page i.e. page2
for (let i = 0; i < nav_bar.length; i++) {
if (e.scroll.y >= 720 && e.scroll.y < 1600) {
nav_bar[i].style.color = "white";
logo.style.fill = "white";
menuSvg.style.stroke = "white";
} else {
nav_bar[i].style.color = "black";
logo.style.fill = "black";
menuSvg.style.stroke = "black";
}
}
});
//on click menu open or close
menuIcon.addEventListener("click", () => {
if (nav_bar[1].style.opacity === "0") {
nav_bar[1].style.opacity = "1";
nav_bar[2].style.opacity = "1";
nav_bar[0].style.transform = `translateX(0px)`;
menuIcon.style.transform = "rotate(45deg)";
} else {
nav_bar[1].style.opacity = "0";
nav_bar[2].style.opacity = "0";
nav_bar[0].style.transform = `translateX(250px)`;
menuIcon.style.transform = "rotate(90deg)";
}
});
};
nav_BarChanges();