-
Notifications
You must be signed in to change notification settings - Fork 0
/
gsap07.html
248 lines (224 loc) · 8.14 KB
/
gsap07.html
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
243
244
245
246
247
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>gsap07</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ScrollTrigger.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ScrollToPlugin.min.js"></script>
<link href="https://webfontworld.github.io/NexonLv1Gothic/NexonLv1Gothic.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/common.css">
<style>
body {
--bg-color: #222;
background-color: var(--bg-color);
}
#parallax__cont {
max-width: 1600px;
width: 98%;
margin: 0 auto;
/* background-color: rgba(255,255,255,0.1); */
}
.parallax__item {
width: 1000px;
max-width: 70vw;
/* background-color: rgba(255,255,255,0.3); */
text-align: left;
margin: 30vw 0 30vw auto;
position: relative;
padding-top: 15vw;
}
.parallax__item:nth-child(even) {
margin-left: 0;
text-align: right;
}
.parallax__item__num {
font-size: 35vw;
position: absolute;
left: -5vw;
top: -13vw;
opacity: 0.07;
font-family: "Lato";
font-weight: 100;
}
.parallax__item:nth-child(even) .parallax__item__num {
left: auto;
right: -5vw;
}
.parallax__item__title {
padding-bottom: 5px;
font-weight: 400;
}
.parallax__item__imgWrap {
width: 100%;
padding-bottom: 56.25%;
background: #000;
position: relative;
overflow: hidden;
}
.parallax__item__img {
position: absolute;
left: -5%;
top: -5%;
width: 110%;
height: 110%;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
filter: saturate(0%);
transition: all 1s;
}
.parallax__item__img:hover {
filter: saturate(100%);
transform: scale(1.025);
}
#section1 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section2 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section3 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section4 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section5 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section6 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section7 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section8 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
#section9 .parallax__item__img {
background-image: url(assets/img/[email protected]);
}
.parallax__item__desc {
font-size: 4vw;
line-height: 1.4;
margin-top: -5vw;
margin-left: -4vw;
z-index: 100;
position: relative;
}
.parallax__item:nth-child(even) .parallax__item__desc {
margin-left: auto;
margin-right: -4vw;
}
</style>
</head>
<body>
<main id="parallax__cont">
<section id="section1" class="parallax__item" data-bgcolor="#111111">
<span class="parallax__item__num">01</span>
<h2 class="parallax__item__title">section1</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">生活不是等待风暴过去,而是学会在雨中翩翩起舞。</p>
</section>
<section id="section2" class="parallax__item" data-bgcolor="#222222">
<span class="parallax__item__num">02</span>
<h2 class="parallax__item__title">section2</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">我们可以失望,但不能盲目。</p>
</section>
<section id="section3" class="parallax__item" data-bgcolor="#333333">
<span class="parallax__item__num">03</span>
<h2 class="parallax__item__title">section3</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">万事得成于忍,与其能辩,不如能忍。</p>
</section>
<section id="section4" class="parallax__item" data-bgcolor="#444444">
<span class="parallax__item__num">04</span>
<h2 class="parallax__item__title">section4</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">任何的限制,都是从自己的内心开始的。</p>
</section>
<section id="section5" class="parallax__item" data-bgcolor="#555555">
<span class="parallax__item__num">05</span>
<h2 class="parallax__item__title">section5</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">没有目标的人永远为有目标的人去努力。</p>
</section>
<section id="section6" class="parallax__item" data-bgcolor="#666666">
<span class="parallax__item__num">06</span>
<h2 class="parallax__item__title">section6</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">遇顺境,处之淡然,遇逆境,处之泰然。</p>
</section>
<section id="section7" class="parallax__item" data-bgcolor="#777777">
<span class="parallax__item__num">07</span>
<h2 class="parallax__item__title">section7</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">含泪播种的人一定能含笑收获。</p>
</section>
<section id="section8" class="parallax__item" data-bgcolor="#888888">
<span class="parallax__item__num">08</span>
<h2 class="parallax__item__title">section8</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">积极进取,机遇总喜欢光顾有准备的头脑。</p>
</section>
<section id="section9" class="parallax__item" data-bgcolor="#999999">
<span class="parallax__item__num">09</span>
<h2 class="parallax__item__title">section9</h2>
<figure class="parallax__item__imgWrap">
<div class="parallax__item__img"></div>
</figure>
<p class="parallax__item__desc">未来的路太长,总有一段路需要自己独行。</p>
</section>
</main>
<script>
// 01: 使用时间线
// let tl = gsap.timeline({
// scrollTrigger: {
// start: 0,
// end: "max",
// scrub: true,
// }
// })
// tl
// .to("body", { "--bg-color": "#333" })
// .to("body", { "--bg-color": "#444" })
// .to("body", { "--bg-color": "#555" })
// 02
gsap.utils.toArray(".parallax__item").forEach(item => {
let color = item.getAttribute("data-bgcolor")
ScrollTrigger.create({
trigger: item,
start: "top 50%",
end: "bottom 50%",
markers: true,
onEnter: () => gsap.to("body", {
backgroundColor: color,
duration: 1.4,
}),
onEnterBack: () => gsap.to("body", {
backgroundColor: color,
duration: 1.4,
}),
})
})
</script>
</body>
</html>