zz-shopify-components 0.0.1-beta.1
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/README.md +12 -0
- package/assets/fade-in-content.js +169 -0
- package/assets/gsap.min.js +11 -0
- package/assets/http-request.js +73 -0
- package/assets/jquery.js +2 -0
- package/assets/lozad.js +10 -0
- package/assets/site-jump.js +52 -0
- package/assets/site-jumpV2.js +35 -0
- package/assets/swiper-bundle.min.css +13 -0
- package/assets/swiper-bundle.min.js +14 -0
- package/assets/swiper.css +331 -0
- package/assets/zz-components.css +323 -0
- package/assets/zz-components.js +166 -0
- package/blocks/zz-accessories-item.liquid +183 -0
- package/blocks/zz-accessories-swiper.liquid +223 -0
- package/blocks/zz-button.liquid +189 -0
- package/blocks/zz-content-description-html.liquid +199 -0
- package/blocks/zz-content-description.liquid +200 -0
- package/blocks/zz-flex-layout-bg-block.liquid +520 -0
- package/blocks/zz-flex-layout-block.liquid +545 -0
- package/blocks/zz-flex-layout-widget.liquid +318 -0
- package/blocks/zz-full-screen-swiper.liquid +444 -0
- package/blocks/zz-icon.liquid +46 -0
- package/blocks/zz-mail.liquid +135 -0
- package/blocks/zz-mb-swiper-pc-flex.liquid +270 -0
- package/blocks/zz-ratio-image.liquid +177 -0
- package/blocks/zz-ratio-video.liquid +112 -0
- package/blocks/zz-responsive-width-image.liquid +219 -0
- package/blocks/zz-responsive-width-video.liquid +163 -0
- package/blocks/zz-scroll-animate-bg-text.liquid +265 -0
- package/blocks/zz-scroll-cover.liquid +64 -0
- package/blocks/zz-tag.liquid +48 -0
- package/blocks/zz-text.liquid +225 -0
- package/blocks/zz-title.liquid +284 -0
- package/blocks/zz-video-button.liquid +81 -0
- package/blocks/zz-video-swiper-perview-item.liquid +216 -0
- package/blocks/zz-video-swiper-perview.liquid +582 -0
- package/component.config.json +4 -0
- package/package.json +23 -0
- package/scripts/postinstall-v2.js +47 -0
- package/scripts/postinstall.js +39 -0
- package/sections/zz-flex-layout-section.liquid +266 -0
- package/sections/zz-navigation-tab-v3.liquid +403 -0
- package/sections/zz-navigation-tab.liquid +410 -0
- package/sections/zz-video-collapse-swiper.liquid +522 -0
- package/sections/zz-video-tab-swiper.liquid +745 -0
- package/snippets/zz-button.liquid +70 -0
- package/snippets/zz-content-text.liquid +56 -0
- package/snippets/zz-h2.liquid +31 -0
- package/snippets/zz-h3.liquid +31 -0
- package/snippets/zz-h4.liquid +30 -0
- package/snippets/zz-h5.liquid +39 -0
- package/snippets/zz-h6.liquid +39 -0
- package/snippets/zz-icon.liquid +74 -0
- package/snippets/zz-img.liquid +44 -0
- package/snippets/zz-prev-next-btn.liquid +62 -0
- package/snippets/zz-spoke.liquid +142 -0
- package/snippets/zz-tag.liquid +22 -0
- package/snippets/zz-video-button.liquid +55 -0
- package/snippets/zz-video-md.liquid +117 -0
- package/snippets/zz-video.liquid +117 -0
|
@@ -0,0 +1,745 @@
|
|
|
1
|
+
{% assign non_collapsible_blocks = section.blocks
|
|
2
|
+
| reject: 'type', 'video'
|
|
3
|
+
%}
|
|
4
|
+
{% assign swiper_blocks = section.blocks | where: 'type', 'video' %}
|
|
5
|
+
{% assign block_size = swiper_blocks.size %}
|
|
6
|
+
|
|
7
|
+
<style>
|
|
8
|
+
#shopify-section-{{ section.id }} {
|
|
9
|
+
background: {{ section.settings.bg_color }};
|
|
10
|
+
padding-top: {{ section.settings.mobile_padding_top }}px;
|
|
11
|
+
padding-bottom: {{ section.settings.mobile_padding_bottom }}px;
|
|
12
|
+
}
|
|
13
|
+
#shopify-section-{{ section.id }} .swiper-slide{
|
|
14
|
+
background: {{ section.settings.bg_color }};
|
|
15
|
+
}
|
|
16
|
+
@media screen and (min-width: 1024px) {
|
|
17
|
+
#shopify-section-{{ section.id }} {
|
|
18
|
+
padding-top: {{ section.settings.pc_padding_top }}px;
|
|
19
|
+
padding-bottom: {{ section.settings.pc_padding_bottom }}px;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
#shopify-section-{{ section.id }} .zz-video-tab-swiper {
|
|
23
|
+
width: 100%;
|
|
24
|
+
letter-spacing: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets {
|
|
28
|
+
bottom: 9px;
|
|
29
|
+
}
|
|
30
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet {
|
|
31
|
+
padding: 0 8px;
|
|
32
|
+
background-color: {{ section.settings.pagination_color }};
|
|
33
|
+
opacity: 0.5;
|
|
34
|
+
}
|
|
35
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet-active {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#shopify-section-{{ section.id }} .swiper-slide-active .active-box-content {
|
|
40
|
+
display: block !important;
|
|
41
|
+
}
|
|
42
|
+
@media screen and (max-width: 1024px) {
|
|
43
|
+
#shopify-section-{{ section.id }} .zz-video-tab-swiper {
|
|
44
|
+
width: 100%;
|
|
45
|
+
padding: 0 20px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper {
|
|
49
|
+
width: 100%;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-slide {
|
|
53
|
+
width: 100% !important;
|
|
54
|
+
}
|
|
55
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-slide .media-box {
|
|
56
|
+
position: relative;
|
|
57
|
+
width: 100%;
|
|
58
|
+
aspect-ratio: 16 / 9;
|
|
59
|
+
}
|
|
60
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets {
|
|
61
|
+
bottom: 85px;
|
|
62
|
+
left: 50%;
|
|
63
|
+
transform: translateX(-50%);
|
|
64
|
+
width: 90vw;
|
|
65
|
+
height: 48px;
|
|
66
|
+
}
|
|
67
|
+
#shopify-section-{{ section.id }} .swiper-pagination-horizontal {
|
|
68
|
+
overflow-x: auto; /* 启用横向滚动 */
|
|
69
|
+
white-space: nowrap; /* 不换行,强制所有子项在一行 */
|
|
70
|
+
-webkit-overflow-scrolling: touch; /* 移动端流畅滚动(可选) */
|
|
71
|
+
scrollbar-width: none; /* Firefox */
|
|
72
|
+
-ms-overflow-style: none; /* IE 和 Edge */
|
|
73
|
+
}
|
|
74
|
+
#shopify-section-{{ section.id }} .swiper-pagination-horizontal::-webkit-scrollbar {
|
|
75
|
+
display: none; /* Chrome, Safari */
|
|
76
|
+
}
|
|
77
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets {
|
|
78
|
+
border-bottom: 1px solid {{ section.settings.mb_tab_line_color }};
|
|
79
|
+
}
|
|
80
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet {
|
|
81
|
+
box-sizing: content-box;
|
|
82
|
+
margin: 0;
|
|
83
|
+
margin-right: 20px;
|
|
84
|
+
width: fit-content;
|
|
85
|
+
height: 47px;
|
|
86
|
+
line-height: 47px;
|
|
87
|
+
border-radius: 0;
|
|
88
|
+
background: none;
|
|
89
|
+
border-top: 0;
|
|
90
|
+
color: {{ section.settings.tab_title_color }};
|
|
91
|
+
opacity: 1;
|
|
92
|
+
font-weight: 700;
|
|
93
|
+
margin-bottom: -1px;
|
|
94
|
+
}
|
|
95
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet:last-child {
|
|
96
|
+
margin: 0;
|
|
97
|
+
}
|
|
98
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet-active {
|
|
99
|
+
border-bottom: 2px solid {{ section.settings.mb_tab_active_line_color }};
|
|
100
|
+
height: 45px;
|
|
101
|
+
line-height: 45px;
|
|
102
|
+
|
|
103
|
+
color: {{ section.settings.tab_title_active_color }};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
@media screen and (min-width: 1024px) {
|
|
108
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper {
|
|
109
|
+
width: 80vw;
|
|
110
|
+
}
|
|
111
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-slide {
|
|
112
|
+
width: 80vw;
|
|
113
|
+
}
|
|
114
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-slide .media-box {
|
|
115
|
+
position: relative;
|
|
116
|
+
width: 80vw;
|
|
117
|
+
height: calc(80vw / 16 * 9);
|
|
118
|
+
}
|
|
119
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets {
|
|
120
|
+
bottom: 135px;
|
|
121
|
+
left: 50%;
|
|
122
|
+
transform: translateX(-50%);
|
|
123
|
+
width: 70vw;
|
|
124
|
+
height: 48px;
|
|
125
|
+
display: flex;
|
|
126
|
+
border-radius: 4px;
|
|
127
|
+
background: {{ section.settings.tab_bar_bg_color }};
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet {
|
|
131
|
+
box-sizing: content-box;
|
|
132
|
+
margin: 0;
|
|
133
|
+
width: calc(100% / {{ block_size }});
|
|
134
|
+
height: 47px;
|
|
135
|
+
line-height: 47px;
|
|
136
|
+
border-radius: 0;
|
|
137
|
+
background: none;
|
|
138
|
+
border-top: 0;
|
|
139
|
+
color: {{ section.settings.tab_title_color }};
|
|
140
|
+
opacity: 1;
|
|
141
|
+
font-weight: 700;
|
|
142
|
+
font-size: 18px;
|
|
143
|
+
}
|
|
144
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets .swiper-pagination-bullet-active {
|
|
145
|
+
border-top: 2px solid {{ section.settings.pc_tab_active_line_color }};
|
|
146
|
+
height: 45px;
|
|
147
|
+
line-height: 45px;
|
|
148
|
+
color: {{ section.settings.tab_title_active_color }};
|
|
149
|
+
font-weight: 700;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
@media screen and (min-width: 1280px) {
|
|
154
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper {
|
|
155
|
+
width: 1220px;
|
|
156
|
+
}
|
|
157
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-slide {
|
|
158
|
+
width: 1220px;
|
|
159
|
+
}
|
|
160
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-slide .media-box {
|
|
161
|
+
position: relative;
|
|
162
|
+
width: 1220px;
|
|
163
|
+
height: 686px;
|
|
164
|
+
}
|
|
165
|
+
#shopify-section-{{ section.id }} .zz-banner-tab-swiper .swiper-pagination-bullets {
|
|
166
|
+
width: 1030px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
</style>
|
|
171
|
+
|
|
172
|
+
<div
|
|
173
|
+
class='zz-video-tab-swiper'
|
|
174
|
+
{% if section.settings.module_name != blank %}data-zz-module-name="{{ section.settings.module_name }}"{% endif %}
|
|
175
|
+
>
|
|
176
|
+
<div class='fade-in-box tw-flex tw-flex-col tw-justify-center'>
|
|
177
|
+
{% for block in non_collapsible_blocks %}
|
|
178
|
+
{% case block.type %}
|
|
179
|
+
{% when 'title' %}
|
|
180
|
+
{% render 'zz-h2',
|
|
181
|
+
title: block.settings.pc_title,
|
|
182
|
+
title_mb: block.settings.mb_title,
|
|
183
|
+
title_color: block.settings.text_color,
|
|
184
|
+
class_name: 'content-title tw-text-center'
|
|
185
|
+
%}
|
|
186
|
+
<style>
|
|
187
|
+
#shopify-section-{{section.id}} .content-title {
|
|
188
|
+
margin-bottom: {{ block.settings.mobile_margin_bottom }}px;
|
|
189
|
+
}
|
|
190
|
+
@media screen and (min-width: 1024px) {
|
|
191
|
+
#shopify-section-{{section.id}} .content-title {
|
|
192
|
+
margin-bottom: {{ block.settings.pc_margin_bottom }}px;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
196
|
+
{% when 'text_content' %}
|
|
197
|
+
{% render 'zz-content-text',
|
|
198
|
+
text: block.settings.pc_text,
|
|
199
|
+
mb_text: block.settings.mb_text,
|
|
200
|
+
text_color: block.settings.text_color,
|
|
201
|
+
class_name: 'content-text tw-text-center'
|
|
202
|
+
%}
|
|
203
|
+
<style>
|
|
204
|
+
#shopify-section-{{section.id}} .content-text {
|
|
205
|
+
margin-bottom: {{ block.settings.mobile_margin_bottom }}px;
|
|
206
|
+
}
|
|
207
|
+
@media screen and (min-width: 1024px) {
|
|
208
|
+
#shopify-section-{{section.id}} .content-text {
|
|
209
|
+
margin-bottom: {{ block.settings.pc_margin_bottom }}px;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
213
|
+
{% endcase %}
|
|
214
|
+
{% endfor %}
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<div class='zz-swiper-container'>
|
|
218
|
+
<div
|
|
219
|
+
class='swiper zz-banner-tab-swiper zz-banner-tab-swiper-{{ section.id }} lg:tw-w-[80vw] xl:tw-w-[64vw]'
|
|
220
|
+
>
|
|
221
|
+
<div class='swiper-wrapper'>
|
|
222
|
+
{% for banner in swiper_blocks %}
|
|
223
|
+
<div class='swiper-slide'>
|
|
224
|
+
<div class='media-box tw-rounded-[10px] lg:tw-rounded-[16px] tw-overflow-hidden'>
|
|
225
|
+
{% if banner.settings.video_pc != blank or banner.settings.video_url_pc != blank %}
|
|
226
|
+
{% if banner.settings.video_url_pc != blank %}
|
|
227
|
+
{% assign pc_video = banner.settings.video_url_pc %}
|
|
228
|
+
{% else %}
|
|
229
|
+
{% assign pc_video = banner.settings.video_pc %}
|
|
230
|
+
{% endif %}
|
|
231
|
+
{% render 'zz-video',
|
|
232
|
+
pc_video: pc_video,
|
|
233
|
+
pc_poster: banner.settings.poster_pc,
|
|
234
|
+
mb_video: banner.settings.video_mb,
|
|
235
|
+
mb_poster: banner.settings.poster_mb,
|
|
236
|
+
lazy: true,
|
|
237
|
+
class: 'tw-w-full tw-h-full tw-object-cover',
|
|
238
|
+
autoplay: true,
|
|
239
|
+
loop: false,
|
|
240
|
+
muted: true
|
|
241
|
+
%}
|
|
242
|
+
{% else %}
|
|
243
|
+
{%- if banner.settings.poster_pc != blank -%}
|
|
244
|
+
{%
|
|
245
|
+
render 'zz-img',
|
|
246
|
+
pc_image: banner.settings.poster_pc,
|
|
247
|
+
mb_image: banner.settings.poster_mb | default: banner.settings.poster_pc,
|
|
248
|
+
image_alt: banner.settings.slide_title | escape,
|
|
249
|
+
%}
|
|
250
|
+
{% endif %}
|
|
251
|
+
{% endif %}
|
|
252
|
+
</div>
|
|
253
|
+
<div class='slide-box tw-mt-[78px] lg:tw-mt-[148px] tw-h-[60px] lg:tw-h-[80px]'>
|
|
254
|
+
<div class='active-box-content tw-hidden slide-content lg:tw-w-[814px] lg:tw-mx-auto tw-mt-[8px]'>
|
|
255
|
+
{% render 'zz-content-text',
|
|
256
|
+
text: banner.settings.slide_content,
|
|
257
|
+
mb_text: banner.settings.slide_content_mb,
|
|
258
|
+
text_color: banner.settings.content_color,
|
|
259
|
+
pc_font_size: 16,
|
|
260
|
+
mobile_font_size: 12,
|
|
261
|
+
pc_text_align: 'center',
|
|
262
|
+
mobile_text_align: 'center'
|
|
263
|
+
%}
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
{% endfor %}
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<!-- Pagination indicator -->
|
|
271
|
+
<div class='swiper-pagination'></div>
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<script>
|
|
277
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
278
|
+
let isDesktop = window.innerWidth > 1023;
|
|
279
|
+
// 添加标题数组
|
|
280
|
+
const slideTitles = [
|
|
281
|
+
{% for block in swiper_blocks %}
|
|
282
|
+
"{{ block.settings.slide_title }}",
|
|
283
|
+
{% endfor %}
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
const swiperClassName = '.zz-banner-tab-swiper-{{ section.id }}';
|
|
287
|
+
const tabSwiper = new Swiper(swiperClassName, {
|
|
288
|
+
loop: true,
|
|
289
|
+
slidesPerView: 'auto',
|
|
290
|
+
centeredSlides: true,
|
|
291
|
+
spaceBetween: isDesktop ? 24 : 8,
|
|
292
|
+
|
|
293
|
+
pagination: {
|
|
294
|
+
el: '.swiper-pagination',
|
|
295
|
+
clickable: true,
|
|
296
|
+
renderBullet: function (index, className) {
|
|
297
|
+
const title = slideTitles[index % slideTitles.length];
|
|
298
|
+
return '<span class="' + className + '">' + title + '</span>';
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
effect: 'fade',
|
|
302
|
+
on: {
|
|
303
|
+
|
|
304
|
+
slideChangeTransitionEnd: function () {
|
|
305
|
+
handleVideoOnSlideChange()
|
|
306
|
+
},
|
|
307
|
+
slideChange: function (e) {
|
|
308
|
+
if (!isDesktop) {
|
|
309
|
+
scrollPaginationToCenter();
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
slideChangeTransitionStart: function () {
|
|
313
|
+
const section = document.getElementById(
|
|
314
|
+
'shopify-section-{{section.id}}'
|
|
315
|
+
);
|
|
316
|
+
const allvideo = section.querySelectorAll('video');
|
|
317
|
+
// 播放当前 active slide 中的视频
|
|
318
|
+
const activeSlide = section.querySelector('.swiper-slide-active');
|
|
319
|
+
const media = getVisibleDisplayMedias(activeSlide);
|
|
320
|
+
if (media.type === 'video') {
|
|
321
|
+
media.video.removeEventListener('ended', endedHandler);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const observer = new IntersectionObserver((entries) => {
|
|
328
|
+
entries.forEach(entry => {
|
|
329
|
+
if (entry.isIntersecting) {
|
|
330
|
+
// 当 swiper-wrapper 第一次出现在视口中时执行
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
handleVideoOnSlideChange();
|
|
333
|
+
}, 200);
|
|
334
|
+
// 执行一次后取消观察
|
|
335
|
+
observer.unobserve(entry.target);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}, {
|
|
339
|
+
threshold: 0.2 // 当 20% 的元素可见时触发
|
|
340
|
+
});
|
|
341
|
+
const section = document.getElementById(
|
|
342
|
+
'shopify-section-{{section.id}}'
|
|
343
|
+
);
|
|
344
|
+
const swiperWrapper = section.querySelector('.swiper-wrapper');
|
|
345
|
+
if (swiperWrapper) {
|
|
346
|
+
observer.observe(swiperWrapper);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
function getVisibleDisplayMedias(container) {
|
|
351
|
+
const videos = container.querySelectorAll('video');
|
|
352
|
+
const video = Array.from(videos).find((video) => {
|
|
353
|
+
const style = window.getComputedStyle(video);
|
|
354
|
+
return style.display !== 'none';
|
|
355
|
+
});
|
|
356
|
+
if (video) {
|
|
357
|
+
return {
|
|
358
|
+
video,
|
|
359
|
+
type: 'video'
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
const images = container.querySelectorAll('img');
|
|
363
|
+
const image = Array.from(images).find((image) => {
|
|
364
|
+
const style = window.getComputedStyle(image);
|
|
365
|
+
return style.display !== 'none';
|
|
366
|
+
});
|
|
367
|
+
if (image) {
|
|
368
|
+
return {
|
|
369
|
+
image,
|
|
370
|
+
type: 'image'
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function scrollPaginationToCenter() {
|
|
378
|
+
// 获取当前section
|
|
379
|
+
const section = document.getElementById(
|
|
380
|
+
'shopify-section-{{section.id}}'
|
|
381
|
+
);
|
|
382
|
+
const paginationContainer = section.querySelector('.swiper-pagination');
|
|
383
|
+
const activeBullet = paginationContainer.querySelector('.swiper-pagination-bullet-active');
|
|
384
|
+
|
|
385
|
+
if (activeBullet) {
|
|
386
|
+
const containerWidth = paginationContainer.offsetWidth;
|
|
387
|
+
const bulletLeft = activeBullet.offsetLeft;
|
|
388
|
+
const bulletWidth = activeBullet.offsetWidth;
|
|
389
|
+
|
|
390
|
+
// 计算需要滚动的位置,使当前bullet居中
|
|
391
|
+
const scrollPosition = bulletLeft - (containerWidth / 2) + (bulletWidth / 2);
|
|
392
|
+
|
|
393
|
+
paginationContainer.scrollTo({
|
|
394
|
+
left: scrollPosition,
|
|
395
|
+
behavior: 'smooth'
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function endedHandler () {
|
|
400
|
+
if (tabSwiper.isEnd) {
|
|
401
|
+
tabSwiper.slideTo(0);
|
|
402
|
+
} else {
|
|
403
|
+
tabSwiper.slideNext();
|
|
404
|
+
}
|
|
405
|
+
this.removeEventListener('ended', endedHandler);
|
|
406
|
+
};
|
|
407
|
+
function handleMediaNext(type, videoDom) {
|
|
408
|
+
if (type === 'video') {
|
|
409
|
+
videoDom.addEventListener('ended', endedHandler);
|
|
410
|
+
} else if (type === 'image') {
|
|
411
|
+
|
|
412
|
+
setTimeout(() => {
|
|
413
|
+
if (tabSwiper.isEnd) {
|
|
414
|
+
tabSwiper.slideTo(0);
|
|
415
|
+
} else {
|
|
416
|
+
tabSwiper.slideNext();
|
|
417
|
+
}
|
|
418
|
+
}, 5000);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function handleVideoOnSlideChange() {
|
|
423
|
+
// 暂停所有视频
|
|
424
|
+
|
|
425
|
+
const section = document.getElementById(
|
|
426
|
+
'shopify-section-{{section.id}}'
|
|
427
|
+
);
|
|
428
|
+
const allvideo = section.querySelectorAll('video');
|
|
429
|
+
// 播放当前 active slide 中的视频
|
|
430
|
+
const activeSlide = section.querySelector('.swiper-slide-active');
|
|
431
|
+
const media = getVisibleDisplayMedias(activeSlide);
|
|
432
|
+
if (media.type === 'video') {
|
|
433
|
+
allvideo.forEach((item) => {
|
|
434
|
+
if (item === media.video) {
|
|
435
|
+
media.video.currentTime = 0;
|
|
436
|
+
media.video.play();
|
|
437
|
+
handleMediaNext('video', media.video);
|
|
438
|
+
|
|
439
|
+
} else {
|
|
440
|
+
item.currentTime = 0;
|
|
441
|
+
item.pause();
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
} else if (media.type === 'image') {
|
|
445
|
+
// 处理图片的情况
|
|
446
|
+
handleMediaNext('image', media.image);
|
|
447
|
+
allvideo.forEach((item) => {
|
|
448
|
+
item.pause();
|
|
449
|
+
item.currentTime = 0;
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
})
|
|
456
|
+
</script>
|
|
457
|
+
|
|
458
|
+
{% schema %}
|
|
459
|
+
{
|
|
460
|
+
"name": "Video Img Swiper Tab",
|
|
461
|
+
"settings": [
|
|
462
|
+
{
|
|
463
|
+
"type": "color",
|
|
464
|
+
"id": "bg_color",
|
|
465
|
+
"default": "#ffffff",
|
|
466
|
+
"label": "背景色"
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
{
|
|
470
|
+
"type": "color",
|
|
471
|
+
"id": "pagination_color",
|
|
472
|
+
"default": "#ffffff",
|
|
473
|
+
"label": "轮播导航圆圈颜色"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"type": "color",
|
|
477
|
+
"id": "tab_bar_bg_color",
|
|
478
|
+
"label": "PC Tab栏背景颜色",
|
|
479
|
+
"default": "#00000012"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"type": "color",
|
|
483
|
+
"id": "tab_title_active_color",
|
|
484
|
+
"label": "Tab标题激活颜色",
|
|
485
|
+
"default": "#000000"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"type": "color",
|
|
489
|
+
"id": "tab_title_color",
|
|
490
|
+
"label": "Tab标题颜色",
|
|
491
|
+
"default": "#767473"
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
"type": "color",
|
|
495
|
+
"id": "pc_tab_active_line_color",
|
|
496
|
+
"label": "PC Tab栏激活划线颜色",
|
|
497
|
+
"default": "#000000"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"type": "color",
|
|
501
|
+
"id": "mb_tab_line_color",
|
|
502
|
+
"label": "移动Tab栏划线颜色",
|
|
503
|
+
"default": "#D9D6D2"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"type": "color",
|
|
507
|
+
"id": "mb_tab_active_line_color",
|
|
508
|
+
"label": "mb Tab栏激活划线颜色",
|
|
509
|
+
"default": "#2B2B2A"
|
|
510
|
+
},
|
|
511
|
+
|
|
512
|
+
{
|
|
513
|
+
"type": "number",
|
|
514
|
+
"id": "pc_padding_top",
|
|
515
|
+
"label": "PC上内边距 (Padding Top)",
|
|
516
|
+
"default": 80
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
"type": "number",
|
|
520
|
+
"id": "pc_padding_bottom",
|
|
521
|
+
"label": "PC下内边距 (Padding Bottom)",
|
|
522
|
+
"default": 80
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"type": "number",
|
|
526
|
+
"id": "mobile_padding_top",
|
|
527
|
+
"label": "移动上内边距 (Padding Top)",
|
|
528
|
+
|
|
529
|
+
"default": 40
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"type": "number",
|
|
533
|
+
"id": "mobile_padding_bottom",
|
|
534
|
+
"label": "移动下内边距 (Padding Bottom)",
|
|
535
|
+
"default": 40
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"type": "text",
|
|
539
|
+
"id": "module_name",
|
|
540
|
+
"label": "模块id",
|
|
541
|
+
"info": "用于定位到本模块"
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
],
|
|
545
|
+
"blocks": [
|
|
546
|
+
{
|
|
547
|
+
"type": "title",
|
|
548
|
+
"name": "标题",
|
|
549
|
+
"settings": [
|
|
550
|
+
{
|
|
551
|
+
"type": "richtext",
|
|
552
|
+
"id": "pc_title",
|
|
553
|
+
"label": "PC标题内容 (PC Title Content)",
|
|
554
|
+
"default": "<p>这里是标题</p>"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
"type": "richtext",
|
|
558
|
+
"id": "mb_title",
|
|
559
|
+
"label": "移动标题内容 (Mobile Title Content)"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"type": "color",
|
|
563
|
+
"id": "text_color",
|
|
564
|
+
"label": "文字颜色",
|
|
565
|
+
"default": "#000000"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"type": "number",
|
|
569
|
+
"id": "pc_margin_bottom",
|
|
570
|
+
"label": "PC下外边距 (Margin Bottom)",
|
|
571
|
+
"default": 40
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"type": "number",
|
|
575
|
+
"id": "mobile_margin_bottom",
|
|
576
|
+
"label": "移动下外边距 (Margin Bottom)",
|
|
577
|
+
"default": 20
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"type": "text_content",
|
|
583
|
+
"name": "文字内容",
|
|
584
|
+
"settings": [
|
|
585
|
+
{
|
|
586
|
+
"type": "richtext",
|
|
587
|
+
"id": "pc_text",
|
|
588
|
+
"label": "PC文字内容 (PC Text Content)",
|
|
589
|
+
"default": "<p>这里是文字内容</p>"
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
"type": "richtext",
|
|
593
|
+
"id": "mb_text",
|
|
594
|
+
"label": "移动文字内容 (Mobile Text Content)",
|
|
595
|
+
"default": "<p>这里是文字内容</p>"
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
"type": "color",
|
|
599
|
+
"id": "text_color",
|
|
600
|
+
"label": "文字颜色",
|
|
601
|
+
"default": "#000000"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"type": "number",
|
|
605
|
+
"id": "pc_margin_bottom",
|
|
606
|
+
"label": "PC下外边距 (Margin Bottom)",
|
|
607
|
+
"default": 40
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"type": "number",
|
|
611
|
+
"id": "mobile_margin_bottom",
|
|
612
|
+
"label": "移动下外边距 (Margin Bottom)",
|
|
613
|
+
"default": 20
|
|
614
|
+
}
|
|
615
|
+
]
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
"name": "Video",
|
|
619
|
+
"type": "video",
|
|
620
|
+
"settings": [
|
|
621
|
+
{
|
|
622
|
+
"type": "text",
|
|
623
|
+
"id": "slide_title",
|
|
624
|
+
"label": "标题"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
"type": "text",
|
|
628
|
+
"id": "video_url_pc",
|
|
629
|
+
"label": "Video url PC",
|
|
630
|
+
"info": "使用cdn视频时,填写视频url。防止视频模糊"
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"type": "video",
|
|
634
|
+
"id": "video_pc",
|
|
635
|
+
"label": "Video"
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
"type": "image_picker",
|
|
639
|
+
"id": "poster_pc",
|
|
640
|
+
"label": "视频封面 PC 没有视频时显示封面"
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"type": "video",
|
|
644
|
+
"id": "video_mb",
|
|
645
|
+
"label": "Video Mobile"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"type": "image_picker",
|
|
649
|
+
"id": "poster_mb",
|
|
650
|
+
"label": "视频封面 Mobile"
|
|
651
|
+
},
|
|
652
|
+
|
|
653
|
+
{
|
|
654
|
+
"type": "richtext",
|
|
655
|
+
"id": "slide_content",
|
|
656
|
+
"label": "内容(PC)"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"type": "richtext",
|
|
660
|
+
"id": "slide_content_mb",
|
|
661
|
+
"label": "内容(Mobile)"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"type": "color",
|
|
665
|
+
"id": "content_color",
|
|
666
|
+
"default": "#8F8882",
|
|
667
|
+
"label": "内容描述颜色"
|
|
668
|
+
}
|
|
669
|
+
]
|
|
670
|
+
}
|
|
671
|
+
],
|
|
672
|
+
"presets": [
|
|
673
|
+
{
|
|
674
|
+
"name": "Tab栏的视频轮播",
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
"name": "Tab栏的视频轮播-预设",
|
|
678
|
+
"settings": {
|
|
679
|
+
"bg_color": "#ffffff",
|
|
680
|
+
"pagination_color": "#ffffff",
|
|
681
|
+
"tab_bar_bg_color": "#00000012",
|
|
682
|
+
"tab_title_active_color": "#000000",
|
|
683
|
+
"tab_title_color": "#767473",
|
|
684
|
+
"pc_tab_active_line_color": "#000000",
|
|
685
|
+
"mb_tab_line_color": "#d9d6d2",
|
|
686
|
+
"mb_tab_active_line_color": "#2b2b2a",
|
|
687
|
+
"pc_padding_top": 80,
|
|
688
|
+
"pc_padding_bottom": 80,
|
|
689
|
+
"mobile_padding_top": 40,
|
|
690
|
+
"mobile_padding_bottom": 40
|
|
691
|
+
},
|
|
692
|
+
"blocks": [
|
|
693
|
+
{
|
|
694
|
+
"type": "title",
|
|
695
|
+
"settings": {
|
|
696
|
+
"pc_title": "<p>Tab栏的视频轮播</p>",
|
|
697
|
+
"mb_title": "<p>Tab栏的视频轮播</p>",
|
|
698
|
+
"text_color": "#010101",
|
|
699
|
+
"pc_margin_bottom": 40,
|
|
700
|
+
"mobile_margin_bottom": 20
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"type": "text_content",
|
|
705
|
+
"settings": {
|
|
706
|
+
"pc_text": "<p>Tab栏的视频轮播 视频与图片 下面是tab栏切换,新增Video Block添加tab选项</p>",
|
|
707
|
+
"mb_text": "<p>Tab栏的视频轮播 视频与图片 下面是<br/>tab栏切换,新增Video Block添加tab选项</p>",
|
|
708
|
+
"text_color": "#010101",
|
|
709
|
+
"pc_margin_bottom": 40,
|
|
710
|
+
"mobile_margin_bottom": 20
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
"type": "video",
|
|
715
|
+
"settings": {
|
|
716
|
+
"slide_title": "Tab name",
|
|
717
|
+
"video_url_pc": "",
|
|
718
|
+
"video_pc": "shopify://files/videos/preset_pc_swiper_video_video.mp4",
|
|
719
|
+
"poster_pc": "shopify://shop_images/preset_pc_swiper_video_poster.png",
|
|
720
|
+
"video_mb": "shopify://files/videos/preset_mobile_swiper_video_video.mp4",
|
|
721
|
+
"poster_mb": "shopify://shop_images/preset_mobile_swiper_video_poster.png",
|
|
722
|
+
"slide_content": "<p>Description set here, Description set here<br/>Description set here<br/></p>",
|
|
723
|
+
"slide_content_mb": "<p>Description set here, Description set here, Description set here</p>",
|
|
724
|
+
"content_color": "#5d544c"
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"type": "video",
|
|
729
|
+
"settings": {
|
|
730
|
+
"slide_title": "Tab name",
|
|
731
|
+
"video_url_pc": "",
|
|
732
|
+
"video_pc": "shopify://files/videos/preset_pc_swiper_video_video_1.mp4",
|
|
733
|
+
"poster_pc": "shopify://shop_images/preset_pc_swiper_video_poster_1.png",
|
|
734
|
+
"video_mb": "shopify://files/videos/preset_mobile_swiper_video_video_1.mp4",
|
|
735
|
+
"poster_mb": "shopify://shop_images/preset_mobile_swiper_video_poster_1.png",
|
|
736
|
+
"slide_content": "<p>Description set here, Description set here<br/>Description set here</p>",
|
|
737
|
+
"slide_content_mb": "<p>Description set here, Description set here<br/>Description set here</p>",
|
|
738
|
+
"content_color": "#5d544c"
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
]
|
|
742
|
+
}
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
{% endschema %}
|