zz-shopify-components 0.3.1-beta.8 → 0.3.1-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.3.1-beta.8",
3
+ "version": "0.3.1-beta.9",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": [
6
6
  "shopify",
@@ -0,0 +1,866 @@
1
+ {% comment %}
2
+ 同时支持video和img的swiper
3
+ {% endcomment %}
4
+
5
+ <style>
6
+ #shopify-section-{{section.id}} {
7
+ padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
8
+ padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
9
+ }
10
+ #shopify-section-{{section.id}} .swiper-banner-video-img p {
11
+ margin: 0;
12
+ }
13
+
14
+
15
+ @media (min-width: 1024px) {
16
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
17
+ width: 100%;
18
+ height: 660px !important;
19
+ }
20
+
21
+ }
22
+ @media (min-width: 1440px) {
23
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
24
+ width: 100%;
25
+ height: 760px !important;
26
+ }
27
+
28
+ }
29
+ @media (min-width: 1640px) {
30
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
31
+ width: 100%;
32
+ height: 860px !important;
33
+ }
34
+
35
+ }
36
+
37
+ #shopify-section-{{section.id}} .swiper-banner-video-img {
38
+ margin-top: -50px;
39
+ width: 100%;
40
+ letter-spacing: 0;
41
+ }
42
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet {
43
+ position: relative;
44
+ background-color: rgba(255, 255, 255, 0.3);
45
+ width: 48px;
46
+ height: 4px;
47
+ border-radius: 10px;
48
+ opacity: 1;
49
+ }
50
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet-active {
51
+ width: 120px;
52
+ /* background-color: #fff; */
53
+ }
54
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-next {
55
+ right: 20px;
56
+ }
57
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-prev {
58
+ left: 20px;
59
+ }
60
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-next,
61
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-prev {
62
+ position: absolute;
63
+ display: block;
64
+ width: 48px;
65
+ height: 48px;
66
+ text-align: center;
67
+ cursor: pointer;
68
+
69
+ }
70
+
71
+ #shopify-section-{{section.id}} .zz-swiper-banner-img-video {
72
+ width: 100% !important;
73
+ height: 100% !important;
74
+ object-fit: cover !important;
75
+ }
76
+
77
+ #shopify-section-{{section.id}} .swiper-button-next:after,
78
+ #shopify-section-{{section.id}} .swiper-button-prev:after{
79
+ display:none;
80
+ }
81
+
82
+ #shopify-section-{{section.id}} .swiper-horizontal>.swiper-pagination-bullets, .swiper-pagination-bullets.swiper-pagination-horizontal{
83
+ bottom:30px;
84
+ }
85
+
86
+
87
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullets .progress-bar {
88
+ position: absolute;
89
+ top: 0;
90
+ left: 0;
91
+ width: 0;
92
+ height: 4px;
93
+ background: #fff;
94
+ border-radius: 10px;
95
+ }
96
+
97
+
98
+ @media (max-width: 1024px) {
99
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
100
+ width: 100%;
101
+ aspect-ratio: 375 / 576;
102
+ }
103
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-next,
104
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-prev {
105
+ display: none;
106
+ }
107
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet {
108
+ width: 24px;
109
+ height: 3px;
110
+ border-radius: 10px;
111
+ }
112
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet-active {
113
+ width: 48px;
114
+ }
115
+ #shopify-section-{{section.id}} .swiper-horizontal>.swiper-pagination-bullets .progress-bar {
116
+ position: absolute;
117
+ top: 0;
118
+ left: 0;
119
+ width: 0;
120
+ height: 3px;
121
+ background: #fff;
122
+ }
123
+ }
124
+ </style>
125
+ {% schema %}
126
+ {
127
+ "name": "Swiper Banner V3",
128
+ "settings": [
129
+ {
130
+ "type": "image_picker",
131
+ "id": "iconRight",
132
+ "label": "右边的导航icon"
133
+ },
134
+ {
135
+ "type": "image_picker",
136
+ "id": "iconleft",
137
+ "label": "左边的导航icon"
138
+ },
139
+ {
140
+ "type": "range",
141
+ "id": "padding_top",
142
+ "min": 0,
143
+ "max": 100,
144
+ "step": 4,
145
+ "unit": "px",
146
+ "label": "t:sections.all.padding.padding_top",
147
+ "default": 0
148
+ },
149
+ {
150
+ "type": "range",
151
+ "id": "padding_bottom",
152
+ "min": 0,
153
+ "max": 100,
154
+ "step": 4,
155
+ "unit": "px",
156
+ "label": "t:sections.all.padding.padding_bottom",
157
+ "default": 0
158
+ }
159
+ ],
160
+ "blocks": [
161
+ {
162
+ "name": "BannerImg",
163
+ "type": "img",
164
+ "settings": [
165
+ {
166
+ "type": "select",
167
+ "id": "theme",
168
+ "label": "Header 主题变化",
169
+ "info": "当前banner对应的header主题变化",
170
+ "options": [
171
+ {
172
+ "value": "dark",
173
+ "label": "Dark"
174
+ },
175
+ {
176
+ "value": "light",
177
+ "label": "Light"
178
+ }
179
+ ]
180
+ },
181
+ {
182
+ "type": "textarea",
183
+ "id": "linksbanner",
184
+ "label": "Sites Link Map banner",
185
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ "
186
+ },
187
+ {
188
+ "type": "select",
189
+ "id": "desc_text_type",
190
+ "label": "描述文字类型",
191
+ "options": [
192
+
193
+ {
194
+ "value": "text",
195
+ "label": "文字,需要填写大小标题"
196
+ },
197
+ {
198
+ "value": "image",
199
+ "label": "图片,需要传标题图片"
200
+ },
201
+ ],
202
+ "default": "text"
203
+ },
204
+ {
205
+ "type": "richtext",
206
+ "id": "title",
207
+ "label": "大标题",
208
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
209
+ },
210
+ {
211
+ "type": "richtext",
212
+ "id": "title_mb",
213
+ "label": "大标题 Mobile",
214
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
215
+ },
216
+ {
217
+ "type": "richtext",
218
+ "id": "subtitle",
219
+ "label": "小标题",
220
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
221
+ },
222
+ {
223
+ "type": "richtext",
224
+ "id": "subtitle_mb",
225
+ "label": "小标题 Mobile",
226
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
227
+ },
228
+ {
229
+ "type": "color",
230
+ "id": "color",
231
+ "label": "Text Color",
232
+ "info": "文本颜色",
233
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
234
+ },
235
+ {
236
+ "type": "image_picker",
237
+ "id": "banner_desc",
238
+ "label": "Banner上悬浮标题图",
239
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
240
+ },
241
+ {
242
+ "type": "image_picker",
243
+ "id": "banner_desc_mb",
244
+ "label": "Banner上悬浮标题图 Mobile",
245
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
246
+ },
247
+
248
+ {
249
+ "type": "number",
250
+ "id": "top_mb",
251
+ "default": 90,
252
+ "label": "移动端顶部距离",
253
+ "info": "移动端文案距离顶部距离 单位PX"
254
+ },
255
+ {
256
+ "type": "image_picker",
257
+ "id": "banner",
258
+ "label": "Banner PC"
259
+ },
260
+ {
261
+ "type": "image_picker",
262
+ "id": "banner_mb",
263
+ "label": "Banner Mobile"
264
+ },
265
+ {
266
+ "type": "text",
267
+ "id": "btn_text",
268
+ "label": "按钮文字",
269
+ "default": "learn more"
270
+ },
271
+ {
272
+ "type": "select",
273
+ "id": "function_type",
274
+ "label": "功能类型",
275
+ "options": [
276
+ {
277
+ "value": "link",
278
+ "label": "链接"
279
+ },
280
+ {
281
+ "value": "link_map",
282
+ "label": "多国家映射"
283
+ },
284
+ ],
285
+ "default": "link"
286
+ },
287
+ {
288
+ "type": "textarea",
289
+ "id": "links",
290
+ "label": "Sites Link Map",
291
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
292
+ "visible_if": "{{ block.settings.function_type == 'link_map' }}"
293
+ },
294
+ {
295
+ "type": "url",
296
+ "id": "link",
297
+ "label": "Normal Button Link",
298
+ "info": "普通按钮跳转地址",
299
+ "visible_if": "{{ block.settings.function_type == 'link' }}"
300
+ },
301
+ {
302
+ "type": "color",
303
+ "id": "btn_border_color",
304
+ "label": "Button Border Color",
305
+ "info": "按钮的边框颜色"
306
+ },
307
+ {
308
+ "type": "color",
309
+ "id": "btn_background_color",
310
+ "label": "Button Background Color",
311
+ "info": "按钮的背景颜色"
312
+ },
313
+ {
314
+ "type": "color",
315
+ "id": "btn_color",
316
+ "label": "Button Text Color",
317
+ "info": "按钮的文本颜色"
318
+ }
319
+ ]
320
+ },
321
+ {
322
+ "name": "BannerVideo",
323
+ "type": "video",
324
+ "settings": [
325
+ {
326
+ "type": "select",
327
+ "id": "theme",
328
+ "label": "Header 主题变化",
329
+ "info": "当前banner对应的header主题变化",
330
+ "options": [
331
+ {
332
+ "value": "dark",
333
+ "label": "Dark"
334
+ },
335
+ {
336
+ "value": "light",
337
+ "label": "Light"
338
+ }
339
+ ]
340
+ },
341
+ {
342
+ "type": "textarea",
343
+ "id": "linksbanner",
344
+ "label": "Sites Link Map banner",
345
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ "
346
+ },
347
+ {
348
+ "type": "select",
349
+ "id": "desc_text_type",
350
+ "label": "描述文字类型",
351
+ "options": [
352
+
353
+ {
354
+ "value": "text",
355
+ "label": "文字,需要填写大小标题"
356
+ },
357
+ {
358
+ "value": "image",
359
+ "label": "图片,需要传标题图片"
360
+ },
361
+ ],
362
+ "default": "text"
363
+ },
364
+ {
365
+ "type": "richtext",
366
+ "id": "title",
367
+ "label": "大标题",
368
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
369
+ },
370
+ {
371
+ "type": "richtext",
372
+ "id": "title_mb",
373
+ "label": "大标题 Mobile",
374
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
375
+ },
376
+ {
377
+ "type": "richtext",
378
+ "id": "subtitle",
379
+ "label": "小标题",
380
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
381
+ },
382
+ {
383
+ "type": "richtext",
384
+ "id": "subtitle_mb",
385
+ "label": "小标题 Mobile",
386
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
387
+ },
388
+ {
389
+ "type": "color",
390
+ "id": "color",
391
+ "label": "Text Color",
392
+ "info": "文本颜色",
393
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
394
+ },
395
+ {
396
+ "type": "image_picker",
397
+ "id": "banner_desc",
398
+ "label": "Banner上悬浮标题图",
399
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
400
+ },
401
+ {
402
+ "type": "image_picker",
403
+ "id": "banner_desc_mb",
404
+ "label": "Banner上悬浮标题图 Mobile",
405
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
406
+ },
407
+
408
+ {
409
+ "type": "number",
410
+ "id": "top_mb",
411
+ "default": 90,
412
+ "label": "移动端顶部距离",
413
+ "info": "移动端文案距离顶部距离 单位PX"
414
+ },
415
+ {
416
+ "type": "video",
417
+ "id": "video_pc",
418
+ "label": "video_pc",
419
+ "info": "pc端的视频"
420
+ },
421
+ {
422
+ "type": "text",
423
+ "id": "video_pc_url",
424
+ "label": "video_pc_url",
425
+ "info": "pc段的视频链接"
426
+ },
427
+ {
428
+ "type": "image_picker",
429
+ "id": "posterPc",
430
+ "label": "poster Pc"
431
+ },
432
+ {
433
+ "type": "video",
434
+ "id": "video_mobile",
435
+ "label": "video_mobile",
436
+ "info": "mobile端的视频"
437
+ },
438
+ {
439
+ "type": "text",
440
+ "id": "video_mobile_url",
441
+ "label": "video_mobile_url",
442
+ "info": "mobile端的视频链接"
443
+ },
444
+ {
445
+ "type": "image_picker",
446
+ "id": "posterMb",
447
+ "label": "poster Mb"
448
+ },
449
+ {
450
+ "type": "text",
451
+ "id": "btn_text",
452
+ "label": "按钮文字",
453
+ "default": "learn more"
454
+ },
455
+ {
456
+ "type": "select",
457
+ "id": "function_type",
458
+ "label": "功能类型",
459
+ "options": [
460
+ {
461
+ "value": "link",
462
+ "label": "链接"
463
+ },
464
+ {
465
+ "value": "link_map",
466
+ "label": "多国家映射"
467
+ },
468
+ ],
469
+ "default": "link"
470
+ },
471
+ {
472
+ "type": "textarea",
473
+ "id": "links",
474
+ "label": "Sites Link Map",
475
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
476
+ "visible_if": "{{ block.settings.function_type == 'link_map' }}"
477
+ },
478
+ {
479
+ "type": "url",
480
+ "id": "link",
481
+ "label": "Normal Button Link",
482
+ "info": "普通按钮跳转地址",
483
+ "visible_if": "{{ block.settings.function_type == 'link' }}"
484
+ },
485
+ {
486
+ "type": "color",
487
+ "id": "btn_border_color",
488
+ "label": "Button Border Color",
489
+ "info": "按钮的边框颜色"
490
+ },
491
+ {
492
+ "type": "color",
493
+ "id": "btn_background_color",
494
+ "label": "Button Background Color",
495
+ "info": "按钮的背景颜色"
496
+ },
497
+ {
498
+ "type": "color",
499
+ "id": "btn_color",
500
+ "label": "Button Text Color",
501
+ "info": "按钮的文本颜色"
502
+ }
503
+ ]
504
+ }
505
+ ],
506
+ "presets": [
507
+ {
508
+ "name": "Swiper Banner V3"
509
+ }
510
+ ]
511
+ }
512
+ {% endschema %}
513
+
514
+
515
+ <div class='swiper swiper-banner-video-img'>
516
+ <div class='swiper-wrapper'>
517
+ {% for banner in section.blocks %}
518
+ <div
519
+ class='swiper-slide tw-h-full'
520
+ data-header-theme='{{ banner.settings.theme }}'
521
+ >
522
+ <div
523
+ id='{{ banner.id }}-bannerlink'
524
+ class='swiper-content tw-w-full tw-max-w-screen tw-relative tw-text-left tw-h-full'
525
+ >
526
+ {%- if banner.type == 'img' -%}
527
+ {% render 'zz-img',
528
+ pc_image: banner.settings.banner,
529
+ mb_image: banner.settings.banner_mb,
530
+ image_alt: banner.settings.title | escape,
531
+ class_name: "zz-swiper-banner-img-video",
532
+ %}
533
+
534
+ {%- elsif banner.type == 'video' -%}
535
+ {% if banner.settings.video_pc_url != blank %}
536
+ {% assign pc_video = banner.settings.video_pc_url %}
537
+ {% else %}
538
+ {% assign pc_video = banner.settings.video_pc %}
539
+ {% endif %}
540
+ {% if banner.settings.video_mobile_url != blank %}
541
+ {% assign mb_video = banner.settings.video_mobile_url %}
542
+ {% else %}
543
+ {% assign mb_video = banner.settings.video_mobile %}
544
+ {% endif %}
545
+ {% render 'zz-video',
546
+ pc_video: pc_video,
547
+ pc_poster: banner.settings.posterPc,
548
+ mb_video: mb_video,
549
+ mb_poster: banner.settings.posterMb,
550
+ class: 'zz-swiper-banner-img-video',
551
+ autoplay: true,
552
+ loop: true,
553
+ muted: true
554
+ %}
555
+ {% endif %}
556
+ <div
557
+ class='tw-absolute lg:tw-left-[50%] lg:tw-top-[50%] lg:tw-translate-x-[-50%] lg:tw-translate-y-[-50%] lg:tw-w-[85vw] xl:tw-w-[1220px] tw-z-10 max-lg:tw-h-full max-lg:tw-top-0 max-lg:tw-left-0 max-lg:tw-w-full max-lg:tw-pt-[90px] tw-box-border max-lg:tw-flex max-lg:tw-flex-col max-lg:tw-items-center'
558
+ >
559
+ <div class='swiper-content-text lg:tw-w-[640px]'>
560
+ {%- if banner.settings.desc_text_type == 'text' -%}
561
+ <div
562
+ class='lg:tw-hidden tw-p-0 tw-leading-[58px] tw-text-[48px] tw-font-bold tw-mb-[24px] max-lg:tw-my-[8px] max-lg:tw-text-[24px] max-lg:tw-leading-[1.2] max-lg:tw-text-center'
563
+ style='color: {{ banner.settings.color | default: 'white' }};'
564
+ >
565
+ {{ banner.settings.title_mb }}
566
+ </div>
567
+ <div
568
+ class='max-lg:tw-hidden tw-p-0 tw-leading-[58px] tw-text-[48px] tw-font-bold tw-mb-[24px] max-lg:tw-my-[8px] max-lg:tw-text-[24px] max-lg:tw-leading-[1.2] max-lg:tw-text-center'
569
+ style='color: {{ banner.settings.color | default: 'white' }};'
570
+ >
571
+ {{ banner.settings.title }}
572
+ </div>
573
+ <div
574
+ class='lg:tw-hidden tw-p-0 tw-m-0 tw-leading-[1.5] tw-text-[28px] tw-font-medium max-lg:tw-text-[14px] max-lg:tw-text-center'
575
+ style='color: {{ banner.settings.color | default: 'white' }}'
576
+ >
577
+ {{ banner.settings.subtitle_mb }}
578
+ </div>
579
+ <div
580
+ class='max-lg:tw-hidden tw-p-0 tw-m-0 tw-leading-[1.5] tw-text-[28px] tw-font-medium max-lg:tw-text-[14px] max-lg:tw-text-center'
581
+ style='color: {{ banner.settings.color | default: 'white' }}'
582
+ >
583
+ {{ banner.settings.subtitle }}
584
+ </div>
585
+ {%- elsif banner.settings.desc_text_type == 'image' -%}
586
+ <div
587
+ class="max-lg:tw-hidden tw-w-[640px]">
588
+ {{
589
+ banner.settings.banner_desc
590
+ | image_url: width: 1280
591
+ | image_tag:
592
+ alt: banner.settings.title,
593
+ class: 'tw-w-full tw-h-auto',
594
+ format: 'webp',
595
+ preload: true,
596
+ fetchpriority:"high"
597
+ }}
598
+
599
+ </div>
600
+ <div
601
+ class="lg:tw-hidden tw-max-w-[480px]">
602
+ {{
603
+ banner.settings.banner_desc_mb
604
+ | image_url: width: 670
605
+ | image_tag:
606
+ alt: banner.settings.title,
607
+ class: 'tw-w-full tw-h-auto',
608
+ format: 'webp',
609
+ preload: true,
610
+ fetchpriority:"high"
611
+ }}
612
+ </div>
613
+ {% endif %}
614
+
615
+
616
+ <div
617
+ class='buttons max-lg:tw-absolute max-lg:tw-bottom-[60px] max-lg:tw-left-[0] max-lg:tw-right-[0] lg:tw-mt-[48px]'
618
+ >
619
+ {%- if banner.settings.function_type == 'link' -%}
620
+ <a
621
+ href='{{ banner.settings.link }}'
622
+ class='tw-w-fit tw-block tw-no-underline tw-h-[48px] max-lg:tw-px-[20px] lg:tw-px-[24px] max-lg:tw-h-[36px] tw-leading-[48px] max-lg:tw-leading-[36px] tw-text-center tw-rounded-full tw-text-[16px] max-lg:tw-text-[13px] max-lg:tw-mx-auto tw-cursor-pointer'
623
+ style='color: {{ banner.settings.btn_color | default: 'black' }}; border: 1px solid {{ banner.settings.btn_border_color | default: 'white' }}; background: {{ banner.settings.btn_background_color | default: 'white' }}'
624
+ >
625
+ {{- banner.settings.btn_text -}}
626
+ </a>
627
+
628
+ {%- elsif banner.settings.function_type == 'link_map' -%}
629
+ <div
630
+ id='{{ banner.id }}-site-btn'
631
+ class='tw-w-fit tw-h-[48px] max-lg:tw-px-[20px] lg:tw-px-[24px] max-lg:tw-h-[36px] tw-leading-[48px] max-lg:tw-leading-[36px] tw-text-center tw-rounded-full tw-text-[16px] max-lg:tw-text-[13px] max-lg:tw-mx-auto tw-cursor-pointer'
632
+ style='color: {{ banner.settings.btn_color | default: 'black' }}; border: 1px solid {{ banner.settings.btn_border_color | default: 'white' }}; background: {{ banner.settings.btn_background_color | default: 'white' }}'
633
+ >
634
+ {{- banner.settings.btn_text -}}
635
+ </div>
636
+ {% endif %}
637
+ </div>
638
+ </div>
639
+ </div>
640
+ </div>
641
+ <script>
642
+ document.addEventListener('DOMContentLoaded', (event) => {
643
+ if(document.getElementById('{{ banner.id }}-site-btn')) {
644
+ bindSiteJump(document.getElementById('{{ banner.id }}-site-btn'), {{ banner.settings.links | json }})
645
+ }
646
+ bindSiteJump(document.getElementById('{{ banner.id }}-bannerlink'), {{ banner.settings.linksbanner | json }})
647
+ })
648
+ </script>
649
+ </div>
650
+ {% endfor %}
651
+ </div>
652
+
653
+ <!-- If we need navigation buttons -->
654
+ <div class='swiper-button-prev'>
655
+ {% render 'zz-prev-next-blur-icon', type: 'prev', color_type: 'light' %}
656
+ </div>
657
+ <div class='swiper-button-next'>
658
+ {% render 'zz-prev-next-blur-icon', type: 'next', color_type: 'light' %}
659
+ </div>
660
+
661
+ <!-- Pagination indicator -->
662
+ <div class='swiper-pagination'></div>
663
+ </div>
664
+
665
+ <script src='{{ 'site-jump.js' | asset_url }}' defer='defer'></script>
666
+
667
+ <script>
668
+ document.addEventListener('DOMContentLoaded', (event) => {
669
+ const VIDEO_IMG_SWIPER = new Swiper('#shopify-section-{{section.id}} .swiper-banner-video-img', {
670
+ loop: true,
671
+ spaceBetween: 0,
672
+ navigation: {
673
+ nextEl: '.swiper-button-next',
674
+ prevEl: '.swiper-button-prev',
675
+ enabled: {% if section.blocks.size > 1 %} true {% else %} false {% endif %}
676
+ },
677
+ pagination: {
678
+ el: '.swiper-pagination',
679
+ clickable: true,
680
+ renderBullet: function (index, className) {
681
+ return `
682
+ <span class="${className}">
683
+ <span class="progress-bar"></span>
684
+ </span>`;
685
+ },
686
+ },
687
+ effect: 'slide',
688
+ on: {
689
+ afterInit: function () {
690
+ const section = document.getElementById('shopify-section-{{section.id}}')
691
+ const allvideo =section.querySelectorAll('video')
692
+ allvideo.forEach((item)=>{
693
+ item.addEventListener('ended', () => {
694
+ // 在这里可以放置你希望在视频播放结束后执行的代码
695
+ setTimeout(() => {
696
+ VIDEO_IMG_SWIPER.slideNext();
697
+ }, 500);
698
+ })
699
+ })
700
+ },
701
+ slideChange: function () {
702
+ const theme = this.slides[this.activeIndex].getAttribute('data-header-theme')
703
+ if(theme) {
704
+ document.querySelector('header-control').setBannerTheme(theme)
705
+ }
706
+ }
707
+ }
708
+ });
709
+
710
+ var timerSwiper = null;
711
+ let progressInterval = null
712
+
713
+ function resetProgress() {
714
+ clearInterval(progressInterval)
715
+ document.querySelectorAll(".swiper-banner-video-img .swiper-pagination-bullet").forEach((bullet) => {
716
+ const progressBar = bullet.querySelector(".progress-bar");
717
+ bullet.style.transition = "0.3s";
718
+ progressBar.style.transition = "none";
719
+ progressBar.style.width = "0";
720
+ });
721
+ }
722
+
723
+ // 判断active dom 是img还是video
724
+ function activeType() {
725
+ var judgeDom = document
726
+ .getElementsByClassName('swiper-banner-video-img')[0]
727
+ .getElementsByClassName('swiper-wrapper')[0]
728
+ .getElementsByClassName('swiper-slide-active')[0]
729
+ .getElementsByClassName('zz-swiper-banner-img-video')[0];
730
+ if (judgeDom.tagName.toLowerCase() === 'video') {
731
+ judgeVideoOrImg = 'video';
732
+ return 'video';
733
+ }
734
+ if (judgeDom.tagName.toLowerCase() === 'img') {
735
+ judgeVideoOrImg = 'img';
736
+ return 'img';
737
+ }
738
+ }
739
+
740
+ {% comment %} 获取当前active的dom的type {% endcomment %}
741
+ var judgeVideoOrImg = activeType();
742
+ // debugger
743
+ console.log('judgeVideoOrImg1',judgeVideoOrImg)
744
+
745
+ {% comment %} 当为video的时候 {% endcomment %}
746
+ if(judgeVideoOrImg==='video'){
747
+
748
+ playit();
749
+ }
750
+ {% comment %} 当为img的时候 {% endcomment %}
751
+ if(judgeVideoOrImg==='img'){
752
+ // console.log('wo shi tup ')
753
+ if(timerSwiper){
754
+ // timerSwiper=null
755
+ clearTimeout(timerSwiper);
756
+ }
757
+ updataMediaProgress('img')
758
+ timerSwiper = setTimeout(function() {
759
+ VIDEO_IMG_SWIPER.slideNext();
760
+ }, 5000);
761
+ }
762
+
763
+
764
+ function updataMediaProgress(type, videoDom) {
765
+ const activeBullet = document.querySelector(".swiper-banner-video-img .swiper-pagination-bullet-active");
766
+ const progressBar = activeBullet.querySelector(".progress-bar");
767
+ if (progressBar) {
768
+ let progress = 0
769
+ if(progressInterval) clearInterval(progressInterval)
770
+ progressInterval = setInterval(() => {
771
+ if(progress >= 1) {
772
+ clearInterval(progressInterval)
773
+ progress = 1
774
+ } else {
775
+ if(type === 'img') {
776
+ progress = 100 / 4800 + progress
777
+ } else {
778
+ progress = videoDom.currentTime / videoDom.duration
779
+ }
780
+ }
781
+ progressBar.style.transition = "0.2s";
782
+ progressBar.style.width = `${(progress) * 100}%`;
783
+ }, 100);
784
+ }
785
+ }
786
+
787
+ // function updataVideoProgress(videoDom) {
788
+ // const activeBullet = document.querySelector(".swiper-banner-video-img .swiper-pagination-bullet-active");
789
+ // const progressBar = activeBullet.querySelector(".progress-bar");
790
+ // if (progressBar) {
791
+ // let progress = 0
792
+ // if(progressInterval) clearInterval(progressInterval)
793
+ // progressInterval = setInterval(() => {
794
+ // if(progress >= 1) {
795
+ // clearInterval(progressInterval)
796
+ // progress = 1
797
+ // } else {
798
+ // }
799
+ // progressBar.style.transition = "0.25s";
800
+ // progressBar.style.width = `${(progress) * 100}%`;
801
+ // }, 200);
802
+ // }
803
+ // }
804
+
805
+ {% comment %} 下一个滑块之后判断类型 {% endcomment %}
806
+ VIDEO_IMG_SWIPER.on('slideChangeTransitionEnd ', function () {
807
+ // console.log('slideChangeTransitionEnd');
808
+ judgeVideoOrImg = activeType();
809
+ if(judgeVideoOrImg==='video'){
810
+ playit();
811
+
812
+ }
813
+ if(judgeVideoOrImg==='img'){
814
+ if(timerSwiper){
815
+ // timerSwiper=null
816
+ clearTimeout(timerSwiper);
817
+ }
818
+ timerSwiper = setTimeout(function() {
819
+ VIDEO_IMG_SWIPER.slideNext();
820
+ }, 5000);
821
+ updataMediaProgress('img')
822
+ }
823
+ })
824
+ {% comment %} 暂停所有的video的播放 {% endcomment %}
825
+ VIDEO_IMG_SWIPER.on('slideChange ', function () {
826
+ resetProgress()
827
+ clearTimeout(timerSwiper);
828
+ endallvideo()
829
+ });
830
+
831
+
832
+
833
+
834
+ {% comment %} 监听当前active video完成 {% endcomment %}
835
+ function playit() {
836
+ // debugger
837
+ // 获取当前激活的slide 的index
838
+ let activeIndex = VIDEO_IMG_SWIPER.activeIndex;
839
+ let active_video = Array.from(
840
+ document
841
+ .getElementsByClassName('swiper-banner-video-img')[0]
842
+ .getElementsByClassName('swiper-wrapper')[0]
843
+ .getElementsByClassName('swiper-slide-active')[0]
844
+ .getElementsByTagName('video')
845
+ ).find(video => getComputedStyle(video).display !== 'none');
846
+
847
+ active_video.play()
848
+ updataMediaProgress('video', active_video)
849
+
850
+ }
851
+
852
+ //将所有的video暂停,然后播放下一个
853
+ function endallvideo() {
854
+ let videoALL = document
855
+ .getElementsByClassName('swiper-banner-video-img')[0]
856
+ .getElementsByClassName('swiper-wrapper')[0]
857
+ .getElementsByClassName('swiper-slide');
858
+ for (var i = 0; i < videoALL.length; i++) {
859
+ // console.log('videoALL[i]', videoALL[i]);
860
+ if(videoALL[i].getElementsByTagName('video')[0]){
861
+ videoALL[i].getElementsByTagName('video')[0].currentTime = 0;
862
+ }
863
+ }
864
+ }
865
+ })
866
+ </script>