-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
143 lines (117 loc) · 2.42 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
let heroH1 = document.querySelector("#section-1 h1")
let heroH1Text = heroH1.textContent
let splittedText = heroH1Text.split("")
let halfLength = splittedText.length/2
let clutter = ""
splittedText.forEach(function(elem,idx){
if(idx>halfLength){
clutter = clutter + `<span class="a" >${elem}</span>`
}else{
clutter = clutter + `<span class="b" >${elem}</span>`
}
});
heroH1.innerHTML = clutter
// yahan tak ka code mene khud likha h ab time nahi h iss liye jaldi jaldi yahan sa code dekh raha hn but its not cheating man
console.log(clutter)
let tl = gsap.timeline();
tl.from("nav h2", {
scale: 0,
duration: 1,
// scrub:5,
delay: 1,
opacity: 0,
});
tl.from("#part-2 h4", {
y: -70,
duration: 0.7,
stagger: 0.2,
});
tl.from(".a",{
y:100,
duration:1,
delay:1,
opacity:0,
stagger:0.3,
})
tl.from(".b",{
y:-100,
duration:1,
delay:1,
opacity:0,
stagger:-0.3,
})
// tl.from("#section-1 h1", {
// y: 20,
// opacity: 0,
// scale: 0.5,
// duration: 0.5,
// });
gsap.to("#section-2 h1", {
transform: "translateX(-120%)",
scrollTrigger: {
trigger: "#section-2",
scroller: "body",
start: "top 0%",
end: "top -150%",
scrub: 2,
pin: true,
},
});
gsap.from(".a",{
y:100,
duration:2,
delay:1,
opacity:0,
})
let initialPath = `M 10 100 Q 450 100 890 100`;
let finalPath = `M 10 100 Q 450 100 890 100`;
let string = document.querySelector("#section-3");
string.addEventListener("mousemove", function (dets) {
initialPath = `M 10 80 Q ${dets.x} ${dets.y} 890 80`;
gsap.to("svg path", {
attr: { d: initialPath },
});
});
string.addEventListener("mouseleave", function (dets) {
gsap.to("svg path", {
attr: { d: finalPath },
duration: 0.3,
ease: "elastic.out(1,0.3)",
});
});
window.addEventListener("wheel", function (dets) {
if (dets.deltaY > 0) {
gsap.to(".looping ", {
x: "0%",
duration: 2,
repeat: -1,
ease: "none",
});
gsap.to(".looping img", {
rotate: 360,
});
} else {
gsap.to(".looping ", {
x: "-100%",
duration: 2,
repeat: -1,
ease: "none",
});
gsap.to(".looping img", {
rotate: 180,
});
}
});
// markers:true,
// x:-1450,
// duration:5,
// gsap.to("#page2
// t ransform: "t " ,
// sc rot t Trigger:
// trigger: "#page2" ,
// scroller: "body",
// ma rkers: true,
// start: "top 0%",
// end: "top —150%" ,
// scrub:2,l
// pin: true