forked from ASHISH26940/toogoodto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
242 lines (212 loc) · 7.09 KB
/
script.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// var color1 = new Color(245, 223, 207);
// var color2 = new Color(195,216,197);
// var color3 = new Color(255, 255, 255);
function locomotiveAnimation() {
gsap.registerPlugin(ScrollTrigger);
const locoScroll = new LocomotiveScroll({
el: document.querySelector("#main"),
smooth: true,
});
locoScroll.on("scroll", ScrollTrigger.update);
ScrollTrigger.scrollerProxy("#main", {
scrollTop(value) {
return arguments.length
? locoScroll.scrollTo(value, 0, 0)
: locoScroll.scroll.instance.scroll.y;
},
getBoundingClientRect() {
return {
top: 0,
left: 0,
width: window.innerWidth,
height: window.innerHeight,
};
},
pinType: document.querySelector("#main").style.transform
? "transform"
: "fixed",
});
ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
ScrollTrigger.refresh();
}
locomotiveAnimation();
function navbarAnimation() {
gsap.to("#nav-part1 svg", {
transform: "translateY(-100%)",
scrollTrigger: {
trigger: "#page1",
scroller: "#main",
start: "top 0",
end: "top -5%",
scrub: true,
},
});
gsap.to("#nav-part2 #links", {
transform: "translateY(-100%)",
opacity: 0,
scrollTrigger: {
trigger: "#page1",
scroller: "#main",
start: "top 0",
end: "top -5%",
scrub: true,
},
});
}
navbarAnimation()
function videoconAnimation() {
var videocon = document.querySelector("#video-container");
var playbtn = document.querySelector("#play");
videocon.addEventListener("mouseenter", function () {
gsap.to(playbtn, {
scale: 1,
opacity: 1,
});
});
videocon.addEventListener("mouseleave", function () {
gsap.to(playbtn, {
scale: 0,
opacity: 0,
});
});
document.addEventListener("mousemove", function (dets) {
gsap.to(playbtn, {
left: dets.x - 70,
top: dets.y - 80,
});
});
}
videoconAnimation();
function loadinganimation() {
gsap.from("#page1 h1", {
y: 100,
opacity: 0,
delay: 0.5,
duration: 0.9,
stagger: 0.3,
});
gsap.from("#page1 #video-container", {
scale: 0.9,
opacity: 0,
delay: 1.3,
duration: 0.5,
});
}
loadinganimation();
function cursorAnimation() {
document.addEventListener("mousemove", function (dets) {
gsap.to("#cursor", {
left: dets.x,
top: dets.y,
});
});
const colors = ["rgba(245, 223, 207)", "pink", "rgb(195,216,197)"];
document.querySelectorAll(".child").forEach(function (elem) {
elem.addEventListener("mouseenter", function () {
const randomColor = colors[Math.floor(Math.random() * colors.length)];
gsap.to("#cursor", {
transform: "translate(-50%,-50%) scale(1)",
backgroundColor:randomColor
});
});
elem.addEventListener("mouseleave", function () {
gsap.to("#cursor", {
transform: "translate(-50%,-50%) scale(0)",
});
});
});
}
cursorAnimation();
// let col= document.querySelector(".col");
// let col1= document.querySelector(".col1");
// let col2= document.querySelector(".col2");
// col.style.backgroundColor="rgb(195,216,197)";
// col1.style.backgroundColor="rgb(245, 223, 207)";
// col2.style.backgroundColor="rgb(255, 255, 255)";
function tsted() {
let tsts = document.querySelectorAll("#tst");
var info = document.querySelector(".info");
tsts.forEach((tst, index) => {
// tst[0].style.backgroundColor="rgb(195, 216, 197)";
// tst[1].style.backgroundColor="rgb(245, 223, 207)";
// tst[2].style.backgroundColor="rgb(255, 255, 255)";
tst.addEventListener("mouseenter", function () {
// Set CSS properties for mouseenter event
// switch (index) {
// case 0:
// tst.style.backgroundColor = "rgb(195, 216, 197)";
// break;
// case 1:
// tst.style.backgroundColor = "rgb(245, 223, 207)";
// break;
// case 2:
// tst.style.backgroundColor = "rgb(255, 255, 255)";
// break;
// // Add more cases for additional elements and colors
// default:
// break;
// }
tst.style.width = "50%";
tst.style.height = "2vw";
tst.style.paddingTop = "2vw";
tst.style.top = "48%";
tst.style.paddingBottom = "10vw";
tst.style.zIndex = "8";
tst.style.position = "absolute";
tst.style.borderRadius = "25px";
});
tst.addEventListener("mouseleave", function () {
// Set CSS properties for mouseleave event to revert to original form
switch (index) {
case 0:
tst.style.backgroundColor = "rgb(195, 216, 197)";
break;
case 1:
tst.style.backgroundColor = "rgb(245, 223, 207)";
break;
case 2:
tst.style.backgroundColor = "rgb(255, 255, 255)";
break;
// Add more cases for additional elements and colors
default:
break;
}
// tst[0].style.backgroundColor = "rgb(195, 216, 197)";
// tst[1].style.backgroundColor = "rgb(245, 223, 207)";
// tst[2].style.backgroundColor = "rgb(255, 255, 255)";
tst.style.height = "2vw";
tst.style.borderRadius = "50px";
tst.style.width = "50%";
tst.style.paddingTop = 0;
tst.style.paddingBottom = "0vw";
tst.style.position = "absolute";
tst.style.zIndex = "9";
// tst.style.backgroundColor = "rgb(195, 216, 197)"; // Set the original color
});
});
}
tsted();
function page2boxes(){
let tsts = document.querySelectorAll("#tst");
}
page2boxes();
document.addEventListener("mousemove", function (dets) {
gsap.to(".cursor", {
left:dets.x,
top:dets.y,
})
})
document.querySelectorAll(".flex1").forEach(function (element) {
element.addEventListener("mouseenter", function () {
gsap.to(".cursor", {
transform: `translate(-50%, -50%) scale(1)`,
});
element.classList.add("cursor-pointer");
});
element.addEventListener("mouseleave", function () {
gsap.to(".cursor", {
transform: `translate(-50%, -50%) scale(0)`,
});
element.classList.remove("cursor-pointer");
});
});