-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
177 lines (156 loc) · 3.78 KB
/
script.js
File metadata and controls
177 lines (156 loc) · 3.78 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
175
176
177
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 loadingAnimation() {
gsap.from('#page1 h1 ', {
y: 100,
opacity: 0,
delay: 0.1,
duration: 0.5,
stagger: 0.3
})
gsap.from('#page1 img ', {
scale: 0,
opacity: 0,
delay: 1,
duration: 0.5,
stagger: 0.3
})
}
loadingAnimation()
function cursorAnimation() {
document.addEventListener('mousemove', function (dets) {
gsap.to('#cursor', {
left: dets.x,
top: dets.y
})
})
document.querySelectorAll('.child').forEach(function (element) {
element.addEventListener('mouseenter', function () {
gsap.to('#cursor', {
transform: `translate(-50%,-50%) scale(1)`
});
});
});
document.querySelectorAll('.child').forEach(function (element) {
element.addEventListener('mouseleave', function () {
gsap.to('#cursor', {
transform: `translate(-50%,-50%) scale(0)`
});
});
});
}
cursorAnimation()
function nav(){
var menu = document.querySelector('#icons #menu')
var cross = document.querySelector('#full i')
var tl = gsap.timeline()
tl.to('#full',{
top:0,
duration: 0.5,
})
tl.from('h4',{
y:40,
duration:0.1,
stagger:0.05,
opacity:0,
})
tl.pause()
menu.addEventListener('click',function(){
tl.timeScale(1);
tl.play()
})
cross.addEventListener('click', function () {
tl.timeScale(3);
tl.reverse();
});
}
nav()
function nav2() {
var cart = document.querySelector('#icons #cart');
var cross = document.querySelector('#full2 i');
var tl = gsap.timeline();
// Open #full2 (slide it down from the top)
tl.to('#full2', {
top: 0,
duration: 0.5,
});
// Animate the text infinitely (you can customize this to make it loop)
tl.from('#full2 h4', {
y: 40,
duration: 0.1,
opacity: 0,
stagger: 0.05,
});
gsap.to('#full2 h4', {
y: -200, // Move the text upwards
duration: 10, // Duration for the full scroll
repeat: -1, // Repeat indefinitely
yoyo: true, // Reverse the direction for a bounce effect
ease: 'none', // No easing to make it move smoothly
delay: 1, // Optional delay before starting the animation
});
// Pause the timeline to start only when triggered
tl.pause();
// Click event to trigger the open animation
cart.addEventListener('click', function () {
tl.timeScale(1);
tl.play();
});
// Click event to trigger the close animation (slide it back up)
cross.addEventListener('click', function () {
tl.timeScale(3);
tl.reverse();
});
}
nav2();