zz-shopify-components 0.3.1-beta.9 → 0.4.0
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/assets/aliyun-oss-sdk-6.20.0.min.js +4 -0
- package/assets/crypto-js.min.js +1 -0
- package/assets/zz-components.css +39 -1
- package/assets/zz-components.js +78 -0
- package/assets/zz-edu-info-dialog.js +123 -0
- package/blocks/zz-button.liquid +0 -3
- package/blocks/zz-content-description.liquid +0 -1
- package/blocks/zz-edu-form.liquid +895 -0
- package/blocks/zz-icon.liquid +0 -1
- package/blocks/zz-normal-swiper.liquid +364 -0
- package/blocks/zz-scroll-animate-bg-text.liquid +0 -1
- package/blocks/zz-tag.liquid +0 -1
- package/blocks/zz-video-button.liquid +0 -2
- package/component.config.json +3 -1
- package/docs/zz-normal-swiper.md +215 -0
- package/package.json +1 -1
- package/sections/zz-modal.liquid +1 -1
- package/sections/zz-navigation-tab-v3.liquid +5 -6
- package/sections/zz-navigation-tab.liquid +0 -1
- package/sections/zz-swiper-banner.liquid +1 -11
- package/snippets/zz-edu-info-dialog.liquid +92 -0
- package/snippets/zz-h2.liquid +0 -1
- package/snippets/zz-h3.liquid +0 -1
- package/snippets/zz-h4.liquid +0 -1
- package/snippets/zz-h5.liquid +0 -1
- package/snippets/zz-h6.liquid +0 -1
- package/snippets/zz-video-button.liquid +0 -1
- package/snippets/zz-video-md.liquid +0 -1
- package/snippets/zz-video.liquid +0 -1
- package/snippets/locksmith-content-variables.liquid +0 -54
- package/snippets/locksmith-variables.liquid +0 -10
- package/snippets/locksmith.liquid +0 -152
package/blocks/zz-icon.liquid
CHANGED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
{% assign block_size = block.blocks.size %}
|
|
2
|
+
|
|
3
|
+
<style>
|
|
4
|
+
#shopify-block-{{block.id}} {
|
|
5
|
+
background: {{ block.settings.bg_color }};
|
|
6
|
+
width: 100%;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
#shopify-block-{{block.id}} .zz-normal-swiper {
|
|
12
|
+
width: 100%;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
position: relative;
|
|
16
|
+
letter-spacing: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#shopify-block-{{block.id}} .swiper-button-next:after,
|
|
20
|
+
#shopify-block-{{block.id}} .swiper-button-prev:after {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#shopify-block-{{block.id}} .zz-normal-swiper .swiper-pagination-bullets {
|
|
25
|
+
bottom: 16px;
|
|
26
|
+
}
|
|
27
|
+
#shopify-block-{{block.id}} .zz-normal-swiper .swiper-pagination-bullet {
|
|
28
|
+
margin: 0 4px;
|
|
29
|
+
width: 6px;
|
|
30
|
+
height: 6px;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
background: {{ block.settings.mb_pagination_color | color_modify: 'alpha', 0.3 }};
|
|
33
|
+
opacity: 1;
|
|
34
|
+
transition: 0.3s;
|
|
35
|
+
}
|
|
36
|
+
#shopify-block-{{block.id}} .zz-normal-swiper .swiper-pagination-bullet-active {
|
|
37
|
+
background: {{ block.settings.mb_pagination_color }};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@media screen and (min-width: 1024px) {
|
|
41
|
+
#shopify-block-{{block.id}} .zz-normal-swiper .swiper-pagination-bullets {
|
|
42
|
+
bottom: 24px;
|
|
43
|
+
}
|
|
44
|
+
#shopify-block-{{block.id}} .zz-normal-swiper .swiper-pagination-bullet {
|
|
45
|
+
margin: 0 6px;
|
|
46
|
+
width: 10px;
|
|
47
|
+
height: 10px;
|
|
48
|
+
border-radius: 10px;
|
|
49
|
+
background: {{ block.settings.pagination_color | color_modify: 'alpha', 0.3 }};
|
|
50
|
+
}
|
|
51
|
+
#shopify-block-{{block.id}} .zz-normal-swiper .swiper-pagination-bullet-active {
|
|
52
|
+
background: {{ block.settings.pagination_color }};
|
|
53
|
+
}
|
|
54
|
+
#shopify-block-{{block.id}} .swiper-button-next,
|
|
55
|
+
#shopify-block-{{block.id}} .swiper-button-prev {
|
|
56
|
+
width: 48px;
|
|
57
|
+
height: 48px;
|
|
58
|
+
top: 50%;
|
|
59
|
+
transform: translateY(-50%);
|
|
60
|
+
}
|
|
61
|
+
#shopify-block-{{block.id}} .swiper-button-prev { left: 16px; }
|
|
62
|
+
#shopify-block-{{block.id}} .swiper-button-next { right: 16px; }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@media screen and (max-width: 1023px) {
|
|
66
|
+
{% if block.settings.show_navigation_mobile == false %}
|
|
67
|
+
#shopify-block-{{block.id}} .swiper-button-next,
|
|
68
|
+
#shopify-block-{{block.id}} .swiper-button-prev { display: none; }
|
|
69
|
+
{% endif %}
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
72
|
+
|
|
73
|
+
<div
|
|
74
|
+
class='zz-normal-swiper swiper zz-normal-swiper-{{ block.id }}'
|
|
75
|
+
>
|
|
76
|
+
<div class='zz-swiper-wrapper swiper-wrapper'>
|
|
77
|
+
{% for block in block.blocks %}
|
|
78
|
+
<div class='swiper-slide'>
|
|
79
|
+
{% render block %}
|
|
80
|
+
</div>
|
|
81
|
+
{% endfor %}
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
{% if block.settings.show_navigation %}
|
|
85
|
+
<div class='swiper-button-prev {% if block_size <= 1 %} tw-hidden {% endif %}'>
|
|
86
|
+
{% render 'zz-prev-next-btn',
|
|
87
|
+
type: 'prev',
|
|
88
|
+
color_type: block.settings.prev_next_type
|
|
89
|
+
%}
|
|
90
|
+
</div>
|
|
91
|
+
<div class='swiper-button-next {% if block_size <= 1 %} tw-hidden {% endif %}'>
|
|
92
|
+
{% render 'zz-prev-next-btn',
|
|
93
|
+
type: 'next',
|
|
94
|
+
color_type: block.settings.prev_next_type
|
|
95
|
+
%}
|
|
96
|
+
</div>
|
|
97
|
+
{% endif %}
|
|
98
|
+
|
|
99
|
+
{% if block.settings.pagination_type != 'none' %}
|
|
100
|
+
<div class='swiper-pagination'></div>
|
|
101
|
+
{% endif %}
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<script>
|
|
105
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
106
|
+
const block = document.getElementById('shopify-block-{{block.id}}');
|
|
107
|
+
const swiperWrapper = block.querySelector('.zz-swiper-wrapper');
|
|
108
|
+
{% comment %} const slides = swiperWrapper ? swiperWrapper.querySelectorAll(':scope > div') : [];
|
|
109
|
+
slides.forEach((slide) => slide.classList.add('swiper-slide'));
|
|
110
|
+
swiperWrapper.classList.add('swiper-wrapper'); {% endcomment %}
|
|
111
|
+
|
|
112
|
+
const swiperSelector = '.zz-normal-swiper-{{ block.id }}';
|
|
113
|
+
let instance = null;
|
|
114
|
+
let initialized = false;
|
|
115
|
+
|
|
116
|
+
const options = {
|
|
117
|
+
loop: {{ block.settings.loop | json }},
|
|
118
|
+
speed: {{ block.settings.speed | default: 500 }},
|
|
119
|
+
autoHeight: {{ block.settings.auto_height | json }},
|
|
120
|
+
centeredSlides: {{ block.settings.centered_slides | json }},
|
|
121
|
+
watchOverflow: true,
|
|
122
|
+
spaceBetween: {{ block.settings.space_between | default: 8 }},
|
|
123
|
+
{% if block.settings.pagination_type != 'none' %}
|
|
124
|
+
pagination: {
|
|
125
|
+
el: '#shopify-block-{{block.id}} .swiper-pagination',
|
|
126
|
+
clickable: true,
|
|
127
|
+
type: '{{ block.settings.pagination_type }}',
|
|
128
|
+
},
|
|
129
|
+
{% endif %}
|
|
130
|
+
{% if block.settings.show_navigation %}
|
|
131
|
+
navigation: {
|
|
132
|
+
nextEl: '#shopify-block-{{block.id}} .swiper-button-next',
|
|
133
|
+
prevEl: '#shopify-block-{{block.id}} .swiper-button-prev',
|
|
134
|
+
},
|
|
135
|
+
{% endif %}
|
|
136
|
+
{% if block.settings.autoplay %}
|
|
137
|
+
autoplay: {
|
|
138
|
+
delay: {{ block.settings.autoplay_delay | default: 4000 }},
|
|
139
|
+
disableOnInteraction: false,
|
|
140
|
+
pauseOnMouseEnter: true,
|
|
141
|
+
},
|
|
142
|
+
{% endif %}
|
|
143
|
+
breakpoints: {
|
|
144
|
+
0: {
|
|
145
|
+
slidesPerView: {{ block.settings.slides_per_view_mb | default: 1 }},
|
|
146
|
+
slidesPerGroup: {{ block.settings.slides_per_group_mb | default: 1 }},
|
|
147
|
+
},
|
|
148
|
+
1024: {
|
|
149
|
+
slidesPerView: {{ block.settings.slides_per_view_pc | default: 3 }},
|
|
150
|
+
slidesPerGroup: {{ block.settings.slides_per_group_pc | default: 1 }},
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
function initSwiper() {
|
|
156
|
+
if (initialized) return;
|
|
157
|
+
initialized = true;
|
|
158
|
+
instance = new Swiper(swiperSelector, options);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const root = block.querySelector(swiperSelector);
|
|
162
|
+
const io = new IntersectionObserver((entries) => {
|
|
163
|
+
entries.forEach((entry) => {
|
|
164
|
+
if (entry.isIntersecting) {
|
|
165
|
+
if (!initialized) initSwiper();
|
|
166
|
+
{% if block.settings.autoplay %}
|
|
167
|
+
if (instance && instance.autoplay) instance.autoplay.start();
|
|
168
|
+
{% endif %}
|
|
169
|
+
} else {
|
|
170
|
+
{% if block.settings.autoplay %}
|
|
171
|
+
if (instance && instance.autoplay) instance.autoplay.stop();
|
|
172
|
+
{% endif %}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}, { threshold: 0.2 });
|
|
176
|
+
|
|
177
|
+
if (root) io.observe(root);
|
|
178
|
+
});
|
|
179
|
+
</script>
|
|
180
|
+
|
|
181
|
+
{% schema %}
|
|
182
|
+
{
|
|
183
|
+
"name": "ZZ Normal Swiper",
|
|
184
|
+
"class": "zz-normal-swiper-block",
|
|
185
|
+
"settings": [
|
|
186
|
+
{
|
|
187
|
+
"type": "color",
|
|
188
|
+
"id": "bg_color",
|
|
189
|
+
"default": "#ffffff",
|
|
190
|
+
"label": "背景色"
|
|
191
|
+
},
|
|
192
|
+
{ "type": "checkbox", "id": "loop", "label": "循环播放", "default": true },
|
|
193
|
+
{
|
|
194
|
+
"type": "range",
|
|
195
|
+
"id": "speed",
|
|
196
|
+
"label": "切换速度(ms)",
|
|
197
|
+
"default": 500,
|
|
198
|
+
"min": 100,
|
|
199
|
+
"max": 5000,
|
|
200
|
+
"step": 50
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "range",
|
|
204
|
+
"id": "space_between",
|
|
205
|
+
"label": "卡片间距(px)",
|
|
206
|
+
"default": 8,
|
|
207
|
+
"min": 0,
|
|
208
|
+
"max": 80,
|
|
209
|
+
"step": 2
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"type": "checkbox",
|
|
213
|
+
"id": "centered_slides",
|
|
214
|
+
"label": "居中显示",
|
|
215
|
+
"default": false
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"type": "checkbox",
|
|
219
|
+
"id": "auto_height",
|
|
220
|
+
"label": "自适应高度",
|
|
221
|
+
"default": false
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
{
|
|
225
|
+
"type": "checkbox",
|
|
226
|
+
"id": "autoplay",
|
|
227
|
+
"label": "自动播放",
|
|
228
|
+
"default": false
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"type": "range",
|
|
232
|
+
"id": "autoplay_delay",
|
|
233
|
+
"label": "自动播放间隔(ms)",
|
|
234
|
+
"default": 4000,
|
|
235
|
+
"min": 1000,
|
|
236
|
+
"max": 9500,
|
|
237
|
+
"step": 500,
|
|
238
|
+
"visible_if": "{{ block.settings.autoplay == true }}"
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
{
|
|
242
|
+
"type": "select",
|
|
243
|
+
"id": "pagination_type",
|
|
244
|
+
"label": "分页器",
|
|
245
|
+
"options": [
|
|
246
|
+
{ "value": "none", "label": "隐藏" },
|
|
247
|
+
{ "value": "bullets", "label": "圆点" },
|
|
248
|
+
{ "value": "fraction", "label": "分式" },
|
|
249
|
+
{ "value": "progressbar", "label": "进度条" }
|
|
250
|
+
],
|
|
251
|
+
"default": "bullets"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"type": "color",
|
|
255
|
+
"id": "pagination_color",
|
|
256
|
+
"default": "#000000",
|
|
257
|
+
"label": "分页器颜色(PC)"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"type": "color",
|
|
261
|
+
"id": "mb_pagination_color",
|
|
262
|
+
"default": "#000000",
|
|
263
|
+
"label": "分页器颜色(Mobile)"
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
{
|
|
267
|
+
"type": "checkbox",
|
|
268
|
+
"id": "show_navigation",
|
|
269
|
+
"label": "显示左右导航",
|
|
270
|
+
"default": true
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"type": "checkbox",
|
|
274
|
+
"id": "show_navigation_mobile",
|
|
275
|
+
"label": "移动端显示导航",
|
|
276
|
+
"default": false,
|
|
277
|
+
"visible_if": "{{ block.settings.show_navigation == true }}"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"type": "select",
|
|
281
|
+
"id": "prev_next_type",
|
|
282
|
+
"label": "导航颜色主题",
|
|
283
|
+
"options": [
|
|
284
|
+
{ "value": "dark", "label": "黑色" },
|
|
285
|
+
{ "value": "light", "label": "白色" }
|
|
286
|
+
],
|
|
287
|
+
"default": "dark"
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
{
|
|
291
|
+
"type": "range",
|
|
292
|
+
"id": "slides_per_view_mb",
|
|
293
|
+
"label": "可见数(Mobile)",
|
|
294
|
+
"default": 1,
|
|
295
|
+
"min": 1,
|
|
296
|
+
"max": 3,
|
|
297
|
+
"step": 0.1
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"type": "range",
|
|
301
|
+
"id": "slides_per_group_mb",
|
|
302
|
+
"label": "每次滑动(Mobile)",
|
|
303
|
+
"default": 1,
|
|
304
|
+
"min": 1,
|
|
305
|
+
"max": 3,
|
|
306
|
+
"step": 1
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"type": "range",
|
|
310
|
+
"id": "slides_per_view_pc",
|
|
311
|
+
"label": "可见数(PC)",
|
|
312
|
+
"default": 3,
|
|
313
|
+
"min": 1,
|
|
314
|
+
"max": 6,
|
|
315
|
+
"step": 0.1
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"type": "range",
|
|
319
|
+
"id": "slides_per_group_pc",
|
|
320
|
+
"label": "每次滑动(PC)",
|
|
321
|
+
"default": 1,
|
|
322
|
+
"min": 1,
|
|
323
|
+
"max": 6,
|
|
324
|
+
"step": 1
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"blocks": [
|
|
328
|
+
{
|
|
329
|
+
"type": "@theme"
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
"presets": [
|
|
333
|
+
{
|
|
334
|
+
"name": "ZZ Normal Swiper",
|
|
335
|
+
"category": "ZZ Components",
|
|
336
|
+
"settings": {
|
|
337
|
+
"bg_color": "#ffffff",
|
|
338
|
+
"loop": true,
|
|
339
|
+
"speed": 500,
|
|
340
|
+
"space_between": 8,
|
|
341
|
+
"centered_slides": false,
|
|
342
|
+
"auto_height": false,
|
|
343
|
+
"autoplay": false,
|
|
344
|
+
"autoplay_delay": 4000,
|
|
345
|
+
"pagination_type": "bullets",
|
|
346
|
+
"pagination_color": "#000000",
|
|
347
|
+
"mb_pagination_color": "#000000",
|
|
348
|
+
"show_navigation": true,
|
|
349
|
+
"show_navigation_mobile": false,
|
|
350
|
+
"prev_next_type": "dark",
|
|
351
|
+
"slides_per_view_mb": 1,
|
|
352
|
+
"slides_per_group_mb": 1,
|
|
353
|
+
"slides_per_view_pc": 3,
|
|
354
|
+
"slides_per_group_pc": 1
|
|
355
|
+
},
|
|
356
|
+
"blocks": [
|
|
357
|
+
{ "type": "zz-flex-layout-block" },
|
|
358
|
+
{ "type": "zz-flex-layout-block" },
|
|
359
|
+
{ "type": "zz-flex-layout-block" }
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
{% endschema %}
|
package/blocks/zz-tag.liquid
CHANGED
package/component.config.json
CHANGED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# ZZ Normal Swiper 组件使用文档
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
`zz-normal-swiper` 是一个基于 Swiper.js 的高性能、可复用轮播组件,支持懒加载初始化、响应式配置、自动播放等功能。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- ✅ **懒加载初始化**:仅在进入可视区域时初始化,节省资源
|
|
10
|
+
- ✅ **响应式设计**:支持 PC/Mobile 不同配置
|
|
11
|
+
- ✅ **自动播放**:可配置间隔时间,支持悬停暂停
|
|
12
|
+
- ✅ **多种分页器**:圆点、分式、进度条可选
|
|
13
|
+
- ✅ **灵活导航**:左右导航按钮,移动端可独立控制
|
|
14
|
+
- ✅ **可定制样式**:支持背景色、分页器颜色等自定义
|
|
15
|
+
- ✅ **性能优化**:IntersectionObserver 自动控制播放状态
|
|
16
|
+
|
|
17
|
+
## 基本使用
|
|
18
|
+
|
|
19
|
+
### 1. 添加组件
|
|
20
|
+
|
|
21
|
+
在 Shopify 主题编辑器中:
|
|
22
|
+
1. 找到需要添加轮播的 Section
|
|
23
|
+
2. 点击"添加区块"
|
|
24
|
+
3. 选择"ZZ Components" → "ZZ Normal Swiper"
|
|
25
|
+
|
|
26
|
+
### 2. 添加内容
|
|
27
|
+
|
|
28
|
+
添加组件后,可以在其中插入子区块作为轮播内容:
|
|
29
|
+
- 默认支持所有主题区块(`@theme`)
|
|
30
|
+
- 推荐使用 `zz-flex-layout-block` 等布局组件
|
|
31
|
+
|
|
32
|
+
## 配置选项
|
|
33
|
+
|
|
34
|
+
### 基础设置
|
|
35
|
+
|
|
36
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
37
|
+
|--------|------|--------|------|
|
|
38
|
+
| `bg_color` | 颜色 | #ffffff | 组件背景色 |
|
|
39
|
+
| `loop` | 复选框 | true | 是否循环播放 |
|
|
40
|
+
| `speed` | 范围 | 500ms | 切换动画速度 (100-5000ms) |
|
|
41
|
+
| `space_between` | 范围 | 8px | 卡片之间的间距 (0-80px) |
|
|
42
|
+
| `centered_slides` | 复选框 | false | 是否居中显示当前卡片 |
|
|
43
|
+
| `auto_height` | 复选框 | false | 是否自适应内容高度 |
|
|
44
|
+
|
|
45
|
+
### 自动播放
|
|
46
|
+
|
|
47
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
48
|
+
|--------|------|--------|------|
|
|
49
|
+
| `autoplay` | 复选框 | false | 是否开启自动播放 |
|
|
50
|
+
| `autoplay_delay` | 范围 | 4000ms | 自动播放间隔 (1000-9500ms) |
|
|
51
|
+
|
|
52
|
+
> 💡 **自动播放特性**:
|
|
53
|
+
> - 组件离开可视区域时自动暂停
|
|
54
|
+
> - 鼠标悬停时暂停播放
|
|
55
|
+
> - 用户交互后不会重置计时器
|
|
56
|
+
|
|
57
|
+
### 分页器设置
|
|
58
|
+
|
|
59
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
60
|
+
|--------|------|--------|------|
|
|
61
|
+
| `pagination_type` | 选择 | bullets | 分页器类型:隐藏/圆点/分式/进度条 |
|
|
62
|
+
| `pagination_color` | 颜色 | #000000 | PC端分页器颜色 |
|
|
63
|
+
| `mb_pagination_color` | 颜色 | #000000 | 移动端分页器颜色 |
|
|
64
|
+
|
|
65
|
+
### 导航设置
|
|
66
|
+
|
|
67
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
68
|
+
|--------|------|--------|------|
|
|
69
|
+
| `show_navigation` | 复选框 | true | 是否显示左右导航按钮 |
|
|
70
|
+
| `show_navigation_mobile` | 复选框 | false | 移动端是否显示导航 |
|
|
71
|
+
| `prev_next_type` | 选择 | dark | 导航按钮主题:黑色/白色 |
|
|
72
|
+
|
|
73
|
+
### 响应式配置
|
|
74
|
+
|
|
75
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
76
|
+
|--------|------|--------|------|
|
|
77
|
+
| `slides_per_view_mb` | 范围 | 1 | 移动端同时显示的卡片数 (1-3,支持小数) |
|
|
78
|
+
| `slides_per_group_mb` | 范围 | 1 | 移动端每次滑动的卡片数 (1-3) |
|
|
79
|
+
| `slides_per_view_pc` | 范围 | 3 | PC端同时显示的卡片数 (1-6,支持小数) |
|
|
80
|
+
| `slides_per_group_pc` | 范围 | 1 | PC端每次滑动的卡片数 (1-6) |
|
|
81
|
+
|
|
82
|
+
## 使用示例
|
|
83
|
+
|
|
84
|
+
### 示例 1:基础产品轮播
|
|
85
|
+
|
|
86
|
+
```liquid
|
|
87
|
+
<!-- 在 Section 中添加 zz-normal-swiper block -->
|
|
88
|
+
<!-- 配置:
|
|
89
|
+
- slides_per_view_pc: 3
|
|
90
|
+
- slides_per_view_mb: 1.2
|
|
91
|
+
- space_between: 16
|
|
92
|
+
- autoplay: true
|
|
93
|
+
- autoplay_delay: 5000
|
|
94
|
+
-->
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 示例 2:全宽图片轮播
|
|
98
|
+
|
|
99
|
+
```liquid
|
|
100
|
+
<!-- 配置:
|
|
101
|
+
- slides_per_view_pc: 1
|
|
102
|
+
- slides_per_view_mb: 1
|
|
103
|
+
- centered_slides: true
|
|
104
|
+
- pagination_type: bullets
|
|
105
|
+
- loop: true
|
|
106
|
+
-->
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 示例 3:卡片预览轮播
|
|
110
|
+
|
|
111
|
+
```liquid
|
|
112
|
+
<!-- 配置:
|
|
113
|
+
- slides_per_view_pc: 4.5
|
|
114
|
+
- slides_per_view_mb: 2.2
|
|
115
|
+
- space_between: 12
|
|
116
|
+
- centered_slides: false
|
|
117
|
+
- show_navigation: true
|
|
118
|
+
- pagination_type: none
|
|
119
|
+
-->
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 样式定制
|
|
123
|
+
|
|
124
|
+
### CSS 变量覆盖
|
|
125
|
+
|
|
126
|
+
```css
|
|
127
|
+
#shopify-block-[block-id] {
|
|
128
|
+
/* 自定义分页器位置 */
|
|
129
|
+
--swiper-pagination-bottom: 20px;
|
|
130
|
+
|
|
131
|
+
/* 自定义导航按钮位置 */
|
|
132
|
+
--swiper-navigation-size: 44px;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 自定义分页器样式
|
|
137
|
+
|
|
138
|
+
```css
|
|
139
|
+
#shopify-block-[block-id] .swiper-pagination-bullet {
|
|
140
|
+
/* 自定义圆点样式 */
|
|
141
|
+
background: #ff6b6b;
|
|
142
|
+
border: 2px solid #fff;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 性能优化
|
|
147
|
+
|
|
148
|
+
### 1. 懒加载机制
|
|
149
|
+
- 组件使用 `IntersectionObserver` 实现懒加载
|
|
150
|
+
- 仅在进入可视区域后初始化 Swiper 实例
|
|
151
|
+
- 离开可视区域时自动暂停自动播放
|
|
152
|
+
|
|
153
|
+
### 2. 内存管理
|
|
154
|
+
- 组件销毁时自动清理事件监听器
|
|
155
|
+
- 避免重复初始化
|
|
156
|
+
|
|
157
|
+
### 3. 性能建议
|
|
158
|
+
- 当 `slides_per_view` > 实际卡片数时,自动禁用循环
|
|
159
|
+
- 图片使用 `loading="lazy"` 属性
|
|
160
|
+
- 避免在轮播中嵌套过于复杂的内容
|
|
161
|
+
|
|
162
|
+
## 常见问题
|
|
163
|
+
|
|
164
|
+
### Q: 轮播不显示?
|
|
165
|
+
A: 检查以下几点:
|
|
166
|
+
1. 确保已添加子区块作为轮播内容
|
|
167
|
+
2. 检查是否正确引入了 Swiper 资源文件
|
|
168
|
+
3. 查看浏览器控制台是否有 JavaScript 错误
|
|
169
|
+
|
|
170
|
+
### Q: 自动播放不工作?
|
|
171
|
+
A: 确认:
|
|
172
|
+
1. `autoplay` 选项已开启
|
|
173
|
+
2. 组件在可视区域内
|
|
174
|
+
3. 没有用户交互导致暂停
|
|
175
|
+
|
|
176
|
+
### Q: 移动端显示异常?
|
|
177
|
+
A: 检查:
|
|
178
|
+
1. `slides_per_view_mb` 设置是否合理
|
|
179
|
+
2. `space_between` 是否过大
|
|
180
|
+
3. 内容宽度是否超出容器
|
|
181
|
+
|
|
182
|
+
### Q: 如何自定义导航按钮?
|
|
183
|
+
A: 导航按钮使用 `zz-prev-next-btn` 组件渲染,可以:
|
|
184
|
+
1. 修改 `prev_next_type` 配置
|
|
185
|
+
2. 自定义 CSS 覆盖样式
|
|
186
|
+
3. 修改 `zz-prev-next-btn.liquid` 模板
|
|
187
|
+
|
|
188
|
+
## 技术依赖
|
|
189
|
+
|
|
190
|
+
- **Swiper.js**: 轮播核心库
|
|
191
|
+
- **IntersectionObserver**: 懒加载和性能优化
|
|
192
|
+
- **zz-prev-next-btn**: 导航按钮组件
|
|
193
|
+
|
|
194
|
+
## 浏览器兼容性
|
|
195
|
+
|
|
196
|
+
- **现代浏览器**: 完全支持
|
|
197
|
+
- **IE 11**: 需要 IntersectionObserver polyfill
|
|
198
|
+
- **移动端**: iOS 10+, Android 5+
|
|
199
|
+
|
|
200
|
+
## 更新日志
|
|
201
|
+
|
|
202
|
+
### v1.0.0
|
|
203
|
+
- 初始版本发布
|
|
204
|
+
- 支持基础轮播功能
|
|
205
|
+
- 懒加载初始化
|
|
206
|
+
- 响应式配置
|
|
207
|
+
- 自动播放功能
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 相关组件
|
|
212
|
+
|
|
213
|
+
- `zz-flex-layout-block`: 推荐的轮播内容布局组件
|
|
214
|
+
- `zz-prev-next-btn`: 导航按钮组件
|
|
215
|
+
- `zz-full-screen-swiper`: 全屏轮播组件
|
package/package.json
CHANGED
package/sections/zz-modal.liquid
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
{% schema %}
|
|
3
2
|
{
|
|
4
3
|
"name": "Navigation Tab V3",
|
|
@@ -205,7 +204,7 @@
|
|
|
205
204
|
tab.addEventListener('click', () => {
|
|
206
205
|
const id = tab.dataset.target;
|
|
207
206
|
const target = document.querySelector(`[data-zz-module-name="${id}"]`);
|
|
208
|
-
const headerHeight = isDesktop ? 64 :
|
|
207
|
+
const headerHeight = isDesktop ? 64 : 50;
|
|
209
208
|
const offsetTop = target.offsetTop - headerHeight;
|
|
210
209
|
scrollPaginationToCenter();
|
|
211
210
|
window.scrollTo(0, offsetTop);
|
|
@@ -247,8 +246,8 @@
|
|
|
247
246
|
if(isDesktop) {
|
|
248
247
|
currentSection.style.top = iptipsBoxHeight + 'px';
|
|
249
248
|
} else {
|
|
250
|
-
// 后期移动端要加上导航栏的高度
|
|
251
|
-
currentSection.style.top = iptipsBoxHeight +
|
|
249
|
+
// 后期移动端要加上导航栏的高度 50
|
|
250
|
+
currentSection.style.top = iptipsBoxHeight + 50 + 'px';
|
|
252
251
|
}
|
|
253
252
|
|
|
254
253
|
} else {
|
|
@@ -256,7 +255,7 @@
|
|
|
256
255
|
if(isDesktop) {
|
|
257
256
|
currentSection.style.top = '0px';
|
|
258
257
|
} else {
|
|
259
|
-
currentSection.style.top = '
|
|
258
|
+
currentSection.style.top = '50px';
|
|
260
259
|
}
|
|
261
260
|
}
|
|
262
261
|
} else {
|
|
@@ -371,7 +370,7 @@
|
|
|
371
370
|
@media screen and (max-width: 1024px) {
|
|
372
371
|
#shopify-section-{{ section.id }} {
|
|
373
372
|
z-index: 499;
|
|
374
|
-
top:
|
|
373
|
+
top: 50px;
|
|
375
374
|
}
|
|
376
375
|
#shopify-section-{{ section.id }} .{{ btn_class }} {
|
|
377
376
|
height: 28px;
|