-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·161 lines (128 loc) · 2.55 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
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
const tween1 = KUTE.fromTo(
'#blob1', { path: '#blob1' }, { path: '#blob2' }, { repeat: 9999, duratuion: 99999, yoyo: true }
)
tween1.start()
const lenis = new Lenis({})
function raf(time) {
//console.log({time})
lenis.raf(time)
requestAnimationFrame(raf)
}
requestAnimationFrame(raf)
const page1Animation = (container) => {
const tl = gsap.timeline()
tl.from("nav h1", {
y: -100,
opacity: 0,
duration: 0.8,
delay: 1
})
tl.from("nav h4", {
y: -30,
opacity: 0,
duration: 0.7,
stagger: 0.3
})
const portfolioTextPage1 = new SplitType("#portfolioTextPage1")
tl.from('.char', {
y: -200,
stagger: 0.1,
delay: 0.5,
duration: 1
})
tl.from(".text .primary-text", {
x: -500,
opacity: 0,
duration: 1,
}, "-=0.8")
tl.from(".text .secondary", {
x: -100,
opacity: 0,
duration: 0.7
}, "-=0.5")
tl.to(".button-page-1", {
y: 0,
duration: 0.6,
opacity: 1
}, "-=0.4")
tl.from(".page-1 img", {
x: 100,
opacity: 0,
duration: 1,
}, "-=1")
const btn = document.querySelector(".button-page-1")
btn.onmousemove = (e) => {
const x = e.pageX - btn.offsetLeft;
const y = e.pageY - btn.offsetTop;
btn.style.setProperty('--x', x + 'px')
btn.style.setProperty('--y', y + 'px')
}
}
gsap.registerPlugin(ScrollTrigger)
const page2 = document.querySelector(".page-2")
function getScrollAmount() {
let page2Width = page2.offsetWidth
return -(page2Width - window.innerWidth)
}
const tween = gsap.to(page2, {
x: getScrollAmount,
duration: 3,
ease: "none"
})
ScrollTrigger.create({
trigger: ".wrapperPage-2",
start: "top 2%",
end: () => `+=${getScrollAmount() * -1}`,
pin: true,
animation: tween,
scrub: 3,
invalidateOnRefresh: true,
})
let tl2 = gsap.timeline({
scrollTrigger: {
trigger: ".page-2",
scroller: "body",
maarkers: true,
start: "top 50%",
end: "top: 0",
scrub: 5,
}
})
tl2.from("#skillText", {
y: 300,
delay: 1,
duration: 3,
opacity: 0,
ease: Power4.easeOut
})
tl2.from(".page-2 .card-1", {
y: -500,
opacity: 0,
duration: 3,
})
tl2.from(".page-2 .card-2", {
y: 500,
opacity: 0,
duration: 0.9,
})
tl2.from(".page-2 .card-3", {
y: -500,
opacity: 0,
duration: 0.9,
})
//paage3
const tl3 = gsap.timeline({scrollTrigger: {
trigger: ".librirariesInJS",
start: "0% 100%",
end: "400% 0%",
scrub: true
}})
tl3.to(".strip-l", {
marginLeft: "0%",
ease: Power4.ease
}, 'strip')
tl3.to(".strip-r", {
marginLeft: "-100%",
ease: Power4.ease
}, 'strip')
page1Animation()