-
Notifications
You must be signed in to change notification settings - Fork 0
/
banner2.html
328 lines (291 loc) · 8.13 KB
/
banner2.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Swiper demo</title>
<!-- Link Swiper's CSS -->
<link rel="stylesheet" href="css/swiper.min.css">
<!-- Demo styles -->
<style>
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper-container {
width: 100%;
height: 100%;
background-color: rgb(179, 189, 196);
transition: 1s background-color 1.3s;
}
.swiper-wrapper {
transition-delay: 1s;
transition-timing-function: cubic-bezier(0.5, 0, 0, 1);
}
.swiper-slide {
text-align: center;
font-size: 18px;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.title {
transition-delay: 1s;
z-index: 10;
}
.title h3 {
font-weight: 700;
font-size: calc(55px + 54 * ((53vw + 53vh) - 520px) / 820);
letter-spacing: -1px;
color: rgba(255, 255, 255, 0);
-webkit-text-stroke: 2px #fff;
}
.img-box {
width: 100%;
height: 100%;
position: absolute;
transform: scale(0.6, 0.6);
transition-duration: 1s;
transition-property: transform;
transition-timing-function: cubic-bezier(0.5, 0, 0, 1);
opacity: 0.9;
overflow: hidden;
}
.img-box img {
width: 100%;
height: 100%;
object-fit: cover;
transform: scale(1.2, 1.2) translateX(50%);
transition-timing-function: cubic-bezier(0.5, 0, 0, 1);
transition-property: transform;
}
.button-prev,
.button-next {
transition: 0.5s;
outline: none;
position: absolute;
width: 140px;
z-index: 10;
top: 65vh;
transform: translateY(-34px);
cursor: pointer;
}
.button-prev {
left: 4vw;
}
.button-next {
right: 4vw;
}
.button.disabled {
opacity: 0.2;
cursor: default;
}
#arrow-svg-home {
transform: translateY(353px);
}
.button-next #arrow-svg-home {
transform: translateY(353px) rotateY(180deg);
transform-origin: 80px 0px 0px;
}
svg {
transition: 0.5s;
}
.cls-1 {
transition: 0.5s;
opacity: 0.4;
transform-origin: -20px 40px;
opacity: 1;
}
.cls-4 {
transition: 0.5s;
stroke-width: 2px;
stroke: #fff;
fill: none;
stroke-dasharray: 1;
stroke-dashoffset: 1;
opacity: 0.4;
transform-origin: 0px 0px 0px;
}
#arrow-trg {
transition: 0.5s;
fill: #fff;
transform: rotateY(180deg) translate(-53px, 39px);
}
#line {
transition: 0.5s;
stroke: #fff;
transform: translate(50px, 42px);
}
.button-prev:not(.disabled):hover svg {
transform: translateX(-25px);
}
.button-next:not(.disabled):hover svg {
transform: translateX(25px);
}
.button:not(.disabled):hover .cls-1 {
transform: scale(1.1);
}
.button:not(.disabled):hover .cls-4 {
stroke-dasharray: 2px;
stroke-dashoffset: 2px;
opacity: 1;
}
.button:not(.disabled):hover #arrow-trg {
transform: rotateY(180deg) translate(-37px, 39px);
}
.button:not(.disabled):hover #line {
transform: translate(35px, 42px) scaleX(0.33);
}
</style>
</head>
<body>
<!-- Swiper -->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="title" data-swiper-parallax="-130%">
<h3>FRENCH FRIES</h3>
</div>
<div class="img-box"><img src="images/img19.jpg" style="transform:translateX(0);"></div>
</div>
<div class="swiper-slide">
<div class="title" data-swiper-parallax="-130%">
<h3>HONEY MUSTARD SAUCE</h3>
</div>
<div class="img-box"><img src="images/img20.jpg"></div>
</div>
<div class="swiper-slide">
<div class="title" data-swiper-parallax="-130%">
<h3>CHEESE STICK</h3>
</div>
<div class="img-box"><img src="images/img21.jpg"></div>
</div>
<div class="swiper-slide">
<div class="title" data-swiper-parallax="-130%">
<h3>CHEESE STICK</h3>
</div>
<div class="img-box"><img src="images/img22.jpg"></div>
</div>
<div class="swiper-slide">
<div class="title" data-swiper-parallax="-130%">
<h3>CHEESE STICK</h3>
</div>
<div class="img-box"><img src="images/img23.jpg"></div>
</div>
<div class="swiper-slide">
<div class="title" data-swiper-parallax="-130%">
<h3>CHEESE STICK</h3>
</div>
<div class="img-box"><img src="images/img24.jpg"></div>
</div>
</div>
<div class="button-prev button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 350 160 90">
<g id="arrow-svg-home">
<g id="circ" class="cls-1">
<circle cx="42" cy="42" r="40" class="cls-4"></circle>
</g>
<g id="arrow">
<path id="arrow-trg" d="M.983,6.929,4.447,3.464.983,0,0,.983,2.482,3.464,0,5.946Z"></path>
</g>
<path id="line" d="M120,0H0" class="cls-3"></path>
</g>
</svg></div>
<!--左箭头-->
<div class="button-next button"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 350 160 90">
<g id="arrow-svg-home">
<g id="circ" class="cls-1">
<circle cx="42" cy="42" r="40" class="cls-4"></circle>
</g>
<g id="arrow">
<path id="arrow-trg" d="M.983,6.929,4.447,3.464.983,0,0,.983,2.482,3.464,0,5.946Z"
class="cls-2"></path>
</g>
<path id="line" d="M120,0H0" class="cls-3"></path>
</g>
</svg></div>
<!--右箭头-->
</div>
<script src="js/swiper.min.js"></script>
<script>
bgColor = ["rgb(179, 189, 196)", "rgb(180, 183, 166)", "rgb(140, 152, 187)"]; //背景色
var mySwiper = new Swiper('.swiper-container', {
autoplay: {
delay: 10000,
},
speed: 1300,
allowTouchMove: false,//禁止触摸滑动
parallax: true, //文字位移视差
on: {
transitionStart: function () {
lock = true;//锁住按钮
slides = this.slides
imgBox = slides.eq(this.previousIndex).find('.img-box') //图片包装器
imgPrev = slides.eq(this.previousIndex).find('img') //当前图片
imgActive = slides.eq(this.activeIndex).find('img') //下一张图片
derection = this.activeIndex - this.previousIndex
this.$el.css("background-color", bgColor[this.activeIndex]);//背景颜色动画
imgBox.transform('matrix(0.6, 0, 0, 0.6, 0, 0)');
imgPrev.transition(1000).transform('matrix(1.2, 0, 0, 1.2, 0, 0)');//图片缩放视差
this.slides.eq(this.previousIndex).find('h3').transition(1000).css('color', 'rgba(255,255,255,0)');//文字透明动画
imgPrev.transitionEnd(function () {
imgActive.transition(1300).transform('translate3d(0, 0, 0) matrix(1.2, 0, 0, 1.2, 0, 0)');//图片位移视差
imgPrev.transition(1300).transform('translate3d(' + 60 * derection + '%, 0, 0) matrix(1.2, 0, 0, 1.2, 0, 0)');
});
},
transitionEnd: function () {
this.slides.eq(this.activeIndex).find('.img-box').transform(' matrix(1, 0, 0, 1, 0, 0)');
imgActive = this.slides.eq(this.activeIndex).find('img')
imgActive.transition(1000).transform(' matrix(1, 0, 0, 1, 0, 0)');
this.slides.eq(this.activeIndex).find('h3').transition(1000).css('color', 'rgba(255,255,255,1)');
imgActive.transitionEnd(function () {
lock = false
});
//第一个和最后一个,禁止按钮
if (this.activeIndex == 0) {
this.$el.find('.button-prev').addClass('disabled');
} else {
this.$el.find('.button-prev').removeClass('disabled');
}
if (this.activeIndex == this.slides.length - 1) {
this.$el.find('.button-next').addClass('disabled');
} else {
this.$el.find('.button-next').removeClass('disabled');
}
},
init: function () {
this.emit('transitionEnd');//在初始化时触发一次transitionEnd事件
},
}
});
//不使用自带的按钮组件,使用lock控制按钮锁定时间
mySwiper.$el.find('.button-next').on('click', function () {
if (!lock) {
mySwiper.slideNext();
}
})
mySwiper.$el.find('.button-prev').on('click', function () {
if (!lock) {
mySwiper.slidePrev();
}
})
</script>
</body>
</html>