zz-shopify-components 0.0.21 → 0.0.22

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +21 -21
  2. package/README.md +56 -56
  3. package/assets/ScrollTrigger.min.js +11 -11
  4. package/assets/gsap.min.js +11 -11
  5. package/assets/jquery.js +2 -2
  6. package/assets/lazy-video.js +2 -2
  7. package/assets/lazyload.min.js +1 -1
  8. package/assets/lozad.js +10 -10
  9. package/assets/site-jump.js +52 -52
  10. package/assets/site-jumpV2.js +35 -35
  11. package/assets/swiper-bundle.min.css +12 -12
  12. package/assets/swiper-bundle.min.js +13 -13
  13. package/assets/swiper.css +330 -330
  14. package/assets/zz-components.css +322 -322
  15. package/assets/zz-components.js +166 -166
  16. package/assets/zz-fade-in-content.js +169 -169
  17. package/blocks/zz-accessories-item.liquid +188 -188
  18. package/blocks/zz-accessories-swiper.liquid +223 -223
  19. package/blocks/zz-button.liquid +216 -216
  20. package/blocks/zz-content-description-html.liquid +201 -201
  21. package/blocks/zz-content-description.liquid +209 -209
  22. package/blocks/zz-flex-layout-bg-block.liquid +524 -524
  23. package/blocks/zz-flex-layout-block.liquid +548 -548
  24. package/blocks/zz-flex-layout-widget.liquid +321 -321
  25. package/blocks/zz-full-screen-swiper.liquid +447 -447
  26. package/blocks/zz-icon.liquid +46 -46
  27. package/blocks/zz-mail.liquid +135 -135
  28. package/blocks/zz-mb-swiper-pc-flex.liquid +273 -273
  29. package/blocks/zz-price-tag-mini.liquid +100 -106
  30. package/blocks/zz-price-tag.liquid +41 -41
  31. package/blocks/zz-ratio-image.liquid +181 -181
  32. package/blocks/zz-ratio-video.liquid +115 -115
  33. package/blocks/zz-responsive-width-image.liquid +222 -222
  34. package/blocks/zz-responsive-width-video.liquid +166 -166
  35. package/blocks/zz-scroll-animate-bg-text.liquid +268 -268
  36. package/blocks/zz-scroll-cover.liquid +67 -67
  37. package/blocks/zz-tag.liquid +50 -50
  38. package/blocks/zz-text.liquid +227 -227
  39. package/blocks/zz-title.liquid +287 -287
  40. package/blocks/zz-video-button.liquid +84 -84
  41. package/blocks/zz-video-swiper-perview-item.liquid +221 -221
  42. package/blocks/zz-video-swiper-perview.liquid +585 -585
  43. package/component.config.json +7 -7
  44. package/package.json +1 -1
  45. package/scripts/postinstall-v1.js +39 -39
  46. package/scripts/postinstall-v2.js +47 -47
  47. package/scripts/postinstall-v3.js +51 -51
  48. package/scripts/publish-npm.js +43 -43
  49. package/sections/zz-flex-layout-section.liquid +269 -269
  50. package/sections/zz-navigation-tab-v3.liquid +407 -407
  51. package/sections/zz-navigation-tab.liquid +411 -411
  52. package/sections/zz-shopping-card-list.liquid +399 -399
  53. package/sections/zz-video-collapse-swiper.liquid +522 -522
  54. package/sections/zz-video-tab-swiper.liquid +748 -748
  55. package/snippets/zz-button.liquid +70 -70
  56. package/snippets/zz-content-h3.liquid +15 -15
  57. package/snippets/zz-content-text.liquid +56 -56
  58. package/snippets/zz-h2.liquid +31 -31
  59. package/snippets/zz-h3.liquid +31 -31
  60. package/snippets/zz-h4.liquid +30 -30
  61. package/snippets/zz-h5.liquid +39 -39
  62. package/snippets/zz-h6.liquid +39 -39
  63. package/snippets/zz-icon-next.liquid +17 -17
  64. package/snippets/zz-icon-prev.liquid +17 -17
  65. package/snippets/zz-icon.liquid +74 -74
  66. package/snippets/zz-img.liquid +44 -44
  67. package/snippets/zz-prev-next-btn.liquid +62 -62
  68. package/snippets/zz-price-tag.liquid +22 -22
  69. package/snippets/zz-spoke.liquid +142 -142
  70. package/snippets/zz-tag.liquid +22 -22
  71. package/snippets/zz-video-button.liquid +54 -54
  72. package/snippets/zz-video-md.liquid +117 -117
  73. package/snippets/zz-video.liquid +117 -117
@@ -1,408 +1,408 @@
1
-
2
- {% schema %}
3
- {
4
- "name": "Navigation Tab V3",
5
- "class": "zz-navigation-tab-section",
6
- "settings": [
7
- {
8
- "type": "color_background",
9
- "id": "background_color",
10
- "label": "背景颜色",
11
- "default": "#000000"
12
- },
13
- {
14
- "type": "image_picker",
15
- "id": "icon",
16
- "label": "icon 图标"
17
- },
18
- {
19
- "type": "text",
20
- "id": "btn_text",
21
- "label": "按钮文字",
22
- "default": "Buy Now"
23
- },
24
- {
25
- "type": "select",
26
- "id": "btn_function_type",
27
- "label": "功能类型",
28
- "options": [
29
- {
30
- "value": "link",
31
- "label": "链接"
32
- },
33
- {
34
- "value": "link_map",
35
- "label": "多国家映射"
36
- },
37
- ],
38
- "default": "link"
39
- },
40
- {
41
- "type": "url",
42
- "id": "url",
43
- "label": "按钮链接",
44
- "visible_if": "{{ section.settings.btn_function_type == 'link' }}"
45
- },
46
- {
47
- "type": "textarea",
48
- "id": "links",
49
- "label": "Sites Link Map",
50
- "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
51
- "visible_if": "{{ section.settings.btn_function_type == 'link_map' }}"
52
- },
53
- {
54
- "type": "text",
55
- "id": "buy_now_click_event_class_name",
56
- "label": "buy now 点击事件统计 classname",
57
- },
58
-
59
-
60
- ],
61
- "blocks": [
62
-
63
- {
64
- "type": "module_name",
65
- "name": "模块名称",
66
- "settings": [
67
- {
68
- "type": "text",
69
- "id": "text",
70
- "label": "模块名称",
71
- },
72
- {
73
- "type": "text",
74
- "id": "module_name",
75
- "label": "模块id",
76
- "info": "用于定位模块"
77
- },
78
- {
79
- "type": "color",
80
- "id": "text_color",
81
- "label": "文字颜色",
82
- "default": "#000000"
83
- },
84
-
85
- ]
86
- },
87
-
88
- ],
89
- "presets": [
90
- {
91
- "name": "Navigation Tab V3"
92
- },
93
- {
94
- "name": "模块导航定位tab栏 V3",
95
- },
96
-
97
- ]
98
- }
99
- {% endschema %}
100
-
101
- {% assign btn_class = 'zz-button' | append: section.id %}
102
-
103
- <div class="tw-w-full tw-px-8">
104
- <div class="zz-navigation-pc-tab max-lg:tw-hidden lg:tw-h-[64px] tw-flex tw-items-center tw-justify-between tw-max-w-[1660px] lg:tw-px-[20px] tw-w-full tw-mx-auto">
105
- <img
106
- class="tw-w-[134px] tw-h-[12px]"
107
- src="{{ section.settings.icon | image_url: width: 200 }}" alt="{{ section.settings.icon.alt }}" width="134" height="12">
108
- <div class="zz-navigation-pc-item-box tw-flex tw-items-center tw-overflow-x-scroll tw-ml-[40px] tw-pr-[60px]">
109
- {% for block in section.blocks %}
110
- <div class="pc-tab-item tw-flex-shrink-0 tw-px-[30px]">
111
-
112
- <span
113
- class="zz-navigation-tab-item-text tw-cursor-pointer tw-text-[#9E9E9E] tw-text-[14px] tw-leading-[14px] tw-font-[400]"
114
- data-target="{{ block.settings.module_name }}"
115
- >{{ block.settings.text }}</span>
116
-
117
- </div>
118
- {% unless forloop.last %}
119
- <div class="pc-tab-item-last tw-w-[1px] tw-h-[16px] tw-bg-[#9E9E9E]">&nbsp;</div>
120
- {% endunless %}
121
- {% endfor %}
122
- </div>
123
- <div class="tw-flex-shrink-0 tw-relative">
124
- <div class="cover-box tw-absolute tw-top-0 tw-left-[-50px] tw-w-[50px] tw-h-full">&nbsp;</div>
125
- {% render 'zz-button',
126
- href: section.settings.url,
127
- type: 'primary',
128
- color: 'white',
129
- text: section.settings.btn_text,
130
- size: 'medium',
131
- class_name: btn_class
132
-
133
- %}
134
- </div>
135
-
136
-
137
- </div>
138
- </div>
139
-
140
- <div class="zz-navigation-mobile-tab lg:tw-hidden tw-h-[52px] tw-flex tw-items-center tw-justify-between tw-px-8">
141
- <div class="mb-navigation-box-item zz-navigation-mb-item-box tw-flex tw-items-center tw-gap-[24px] tw-pr-[120px] tw-h-[52px] tw-overflow-x-scroll">
142
- {% for block in section.blocks %}
143
- <div class="pc-tab-item tw-flex-shrink-0">
144
-
145
- <span
146
- class="zz-navigation-tab-item-text tw-cursor-pointer tw-text-[#9E9E9E] tw-text-[13px] tw-leading-[13px] tw-font-[400]"
147
- data-target="{{ block.settings.module_name }}"
148
- >{{ block.settings.text }}</span>
149
-
150
- </div>
151
- {% endfor %}
152
- </div>
153
- <div class="tw-flex-shrink-0 tw-relative">
154
- <div class="cover-box tw-absolute tw-top-0 tw-left-[-40px] tw-w-[40px] tw-h-full">&nbsp;</div>
155
- {% render 'zz-button',
156
- href: section.settings.url,
157
- type: 'primary',
158
- color: 'white',
159
- text: section.settings.btn_text,
160
- size: 'small',
161
- class_name: btn_class
162
- %}
163
- </div>
164
- </div>
165
-
166
- <script>
167
- document.addEventListener('DOMContentLoaded', (event) => {
168
- const isDesktop = window.innerWidth > 1024;
169
-
170
- function scrollPaginationToCenter() {
171
- // 获取当前section
172
- const section = document.getElementById(
173
- 'shopify-section-{{section.id}}'
174
- );
175
- const paginationContainer = isDesktop ? section.querySelector('.zz-navigation-pc-item-box') : section.querySelector('.zz-navigation-mb-item-box');
176
- const activeBullet = paginationContainer.querySelector('.zz-navigation-active-text');
177
-
178
- if (activeBullet) {
179
- const containerWidth = paginationContainer.offsetWidth;
180
- const bulletLeft = activeBullet.offsetLeft;
181
- const bulletWidth = activeBullet.offsetWidth;
182
-
183
- // 计算需要滚动的位置,使当前bullet居中
184
- const scrollPosition = bulletLeft - (containerWidth / 2) + (bulletWidth / 2);
185
-
186
- paginationContainer.scrollTo({
187
- left: scrollPosition,
188
- behavior: 'smooth'
189
- });
190
- }
191
- }
192
-
193
- const currentSection = document.getElementById(
194
- 'shopify-section-{{section.id}}'
195
- );
196
- // 获取通知栏以及顶部弹窗 调整sticky的top。id="IPTipsBox",id="zz-quick-announcement-bar-container"
197
- const iptipsBox = document.getElementById('IPTipsBox');
198
- const pcDropdowns = document.querySelectorAll('.menu-wrapper');
199
- const tabs = currentSection.querySelectorAll('.zz-navigation-tab-item-text');
200
-
201
- const sections = document.querySelectorAll('[data-zz-module-name]');//document.querySelectorAll('.zz-navigation-moudule');
202
- let showPcDropdowns = []
203
- // 点击 tab 滚动
204
- tabs.forEach(tab => {
205
- tab.addEventListener('click', () => {
206
- const id = tab.dataset.target;
207
- const target = document.querySelector(`[data-zz-module-name="${id}"]`);
208
- const headerHeight = isDesktop ? 64 : 44;
209
- const offsetTop = target.offsetTop - headerHeight;
210
- scrollPaginationToCenter();
211
- window.scrollTo(0, offsetTop);
212
- dataLayer.push({
213
- event: "141_productpage_click_header_tab_item",
214
- timestamp: new Date().toISOString(),
215
- header_module_name: id,
216
- });
217
- });
218
- });
219
-
220
- // 监听滚动,高亮 tab
221
- const observerOptions = {
222
- root: null,
223
- rootMargin: '0px 0px 0px 0px',
224
- threshold: 0.1
225
- };
226
-
227
- const observer = new IntersectionObserver(entries => {
228
- entries.forEach(entry => {
229
- if (entry.isIntersecting) {
230
- const id = entry.target.dataset.zzModuleName;
231
- tabs.forEach(tab => {
232
- tab.classList.toggle('zz-navigation-active-text', tab.dataset.target === id);
233
- scrollPaginationToCenter();
234
-
235
- });
236
- }
237
-
238
- });
239
- }, observerOptions);
240
- const headerObserver = new IntersectionObserver(entries => {
241
- entries.forEach(entry => {
242
- if (entry.target == iptipsBox) {
243
-
244
- if (entry.isIntersecting) {
245
- // 计算iptipsBox的高度,并设置sticky的top
246
- const iptipsBoxHeight = entry.target.offsetHeight;
247
- if(isDesktop) {
248
- currentSection.style.top = iptipsBoxHeight + 'px';
249
- } else {
250
- // 后期移动端要加上导航栏的高度 44
251
- currentSection.style.top = iptipsBoxHeight + 44 + 'px';
252
- }
253
-
254
- } else {
255
-
256
- if(isDesktop) {
257
- currentSection.style.top = '0px';
258
- } else {
259
- currentSection.style.top = '44px';
260
- }
261
- }
262
- } else {
263
- if(entry.isIntersecting) {
264
- if(!showPcDropdowns.includes(entry.target)) {
265
- showPcDropdowns.push(entry.target);
266
- }
267
- } else {
268
- showPcDropdowns = showPcDropdowns.filter(dropdown => dropdown !== entry.target);
269
- }
270
- if(isDesktop) {
271
- if(showPcDropdowns.length > 0) {
272
- currentSection.style.zIndex = '490';
273
- } else {
274
- currentSection.style.zIndex = '501';
275
- }
276
- }
277
- }
278
-
279
- });
280
- }, {
281
- root: null,
282
- rootMargin: '0px 0px 0px 0px',
283
- threshold: 0
284
- });
285
-
286
-
287
- sections.forEach(section => observer.observe(section));
288
- headerObserver.observe(iptipsBox);
289
- pcDropdowns.forEach(dropdown => headerObserver.observe(dropdown));
290
- function handlePCTouchScroll () {
291
- const el = document.querySelector('.zz-navigation-pc-item-box');
292
- let isDown = false;
293
- let startX, scrollLeft;
294
-
295
- el.addEventListener('mousedown', e => {
296
- isDown = true;
297
- el.classList.add('dragging');
298
- startX = e.pageX;
299
- scrollLeft = el.scrollLeft;
300
- });
301
-
302
- el.addEventListener('mouseleave', () => isDown = false);
303
- el.addEventListener('mouseup', () => isDown = false);
304
- el.addEventListener('mousemove', e => {
305
- if (!isDown) return;
306
- e.preventDefault();
307
- const x = e.pageX;
308
- const walk = x - startX;
309
- el.scrollLeft = scrollLeft - walk;
310
- });
311
-
312
- }
313
- handlePCTouchScroll();
314
-
315
- const btns = document.querySelectorAll('.{{ btn_class }}');
316
- btns.forEach(btn => {
317
- btn.addEventListener('click', (event) => {
318
- dataLayer.push({
319
- event: "{{ section.settings.buy_now_click_event_class_name }}",
320
- timestamp: new Date().toISOString(),
321
- });
322
- });
323
- {% if section.settings.btn_function_type == 'link_map' %}
324
- if(window.bindSiteJump) {
325
- bindSiteJump(btn, {{ section.settings.links | json }})
326
- }
327
- {% endif %}
328
- })
329
-
330
- })
331
- </script>
332
- <style>
333
- #shopify-section-{{ section.id }} {
334
- position: sticky;
335
- width: 100%;
336
- background-color: {{ section.settings.background_color }};
337
- }
338
-
339
- #shopify-section-{{ section.id }} .zz-navigation-mobile-tab {
340
-
341
- }
342
- #shopify-section-{{ section.id }} .zz-navigation-pc-tab {
343
- width: 100%;
344
- box-sizing: border-box;
345
-
346
-
347
- }
348
- #shopify-section-{{ section.id }} .cover-box {
349
- background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, #000000 100%);
350
-
351
- }
352
- #shopify-section-{{ section.id }} .zz-navigation-active-text {
353
- font-weight: 700;
354
- color: #FFFFFF;
355
- }
356
- #shopify-section-{{ section.id }} .zz-navigation-mobile-tab {
357
- border-bottom: 0.5px solid #FFFFFF26;
358
- }
359
- #shopify-section-{{ section.id }} .{{ btn_class }} {
360
- flex-shrink: 0;
361
- }
362
- @media screen and (min-width: 1024px) {
363
- #shopify-section-{{ section.id }} {
364
- z-index: 501;
365
- top: 0;
366
- }
367
-
368
- }
369
- @media screen and (max-width: 1024px) {
370
- #shopify-section-{{ section.id }} {
371
- z-index: 499;
372
- top: 44px;
373
- }
374
- #shopify-section-{{ section.id }} .{{ btn_class }} {
375
- height: 28px;
376
- padding: 0 16px;
377
- }
378
- }
379
-
380
- .zz-navigation-pc-item-box {
381
- overflow-x: auto;
382
- overflow-y: hidden;
383
- scrollbar-width: none; /* Firefox */
384
- -ms-overflow-style: none; /* IE 10+ */
385
- }
386
- html {
387
- scroll-behavior: auto;
388
- }
389
- .zz-navigation-pc-item-box::-webkit-scrollbar {
390
- width: 0;
391
- height: 0;
392
- display: none; /* Chrome/Safari/Edge */
393
- }
394
- .zz-navigation-mb-item-box {
395
- overflow-x: auto;
396
- overflow-y: hidden;
397
- scrollbar-width: none; /* Firefox */
398
- -ms-overflow-style: none; /* IE 10+ */
399
- }
400
-
401
- .zz-navigation-mb-item-box::-webkit-scrollbar {
402
- width: 0;
403
- height: 0;
404
- display: none; /* Chrome/Safari/Edge */
405
- }
406
-
407
-
1
+
2
+ {% schema %}
3
+ {
4
+ "name": "Navigation Tab V3",
5
+ "class": "zz-navigation-tab-section",
6
+ "settings": [
7
+ {
8
+ "type": "color_background",
9
+ "id": "background_color",
10
+ "label": "背景颜色",
11
+ "default": "#000000"
12
+ },
13
+ {
14
+ "type": "image_picker",
15
+ "id": "icon",
16
+ "label": "icon 图标"
17
+ },
18
+ {
19
+ "type": "text",
20
+ "id": "btn_text",
21
+ "label": "按钮文字",
22
+ "default": "Buy Now"
23
+ },
24
+ {
25
+ "type": "select",
26
+ "id": "btn_function_type",
27
+ "label": "功能类型",
28
+ "options": [
29
+ {
30
+ "value": "link",
31
+ "label": "链接"
32
+ },
33
+ {
34
+ "value": "link_map",
35
+ "label": "多国家映射"
36
+ },
37
+ ],
38
+ "default": "link"
39
+ },
40
+ {
41
+ "type": "url",
42
+ "id": "url",
43
+ "label": "按钮链接",
44
+ "visible_if": "{{ section.settings.btn_function_type == 'link' }}"
45
+ },
46
+ {
47
+ "type": "textarea",
48
+ "id": "links",
49
+ "label": "Sites Link Map",
50
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
51
+ "visible_if": "{{ section.settings.btn_function_type == 'link_map' }}"
52
+ },
53
+ {
54
+ "type": "text",
55
+ "id": "buy_now_click_event_class_name",
56
+ "label": "buy now 点击事件统计 classname",
57
+ },
58
+
59
+
60
+ ],
61
+ "blocks": [
62
+
63
+ {
64
+ "type": "module_name",
65
+ "name": "模块名称",
66
+ "settings": [
67
+ {
68
+ "type": "text",
69
+ "id": "text",
70
+ "label": "模块名称",
71
+ },
72
+ {
73
+ "type": "text",
74
+ "id": "module_name",
75
+ "label": "模块id",
76
+ "info": "用于定位模块"
77
+ },
78
+ {
79
+ "type": "color",
80
+ "id": "text_color",
81
+ "label": "文字颜色",
82
+ "default": "#000000"
83
+ },
84
+
85
+ ]
86
+ },
87
+
88
+ ],
89
+ "presets": [
90
+ {
91
+ "name": "Navigation Tab V3"
92
+ },
93
+ {
94
+ "name": "模块导航定位tab栏 V3",
95
+ },
96
+
97
+ ]
98
+ }
99
+ {% endschema %}
100
+
101
+ {% assign btn_class = 'zz-button' | append: section.id %}
102
+
103
+ <div class="tw-w-full tw-px-8">
104
+ <div class="zz-navigation-pc-tab max-lg:tw-hidden lg:tw-h-[64px] tw-flex tw-items-center tw-justify-between tw-max-w-[1660px] lg:tw-px-[20px] tw-w-full tw-mx-auto">
105
+ <img
106
+ class="tw-w-[134px] tw-h-[12px]"
107
+ src="{{ section.settings.icon | image_url: width: 200 }}" alt="{{ section.settings.icon.alt }}" width="134" height="12">
108
+ <div class="zz-navigation-pc-item-box tw-flex tw-items-center tw-overflow-x-scroll tw-ml-[40px] tw-pr-[60px]">
109
+ {% for block in section.blocks %}
110
+ <div class="pc-tab-item tw-flex-shrink-0 tw-px-[30px]">
111
+
112
+ <span
113
+ class="zz-navigation-tab-item-text tw-cursor-pointer tw-text-[#9E9E9E] tw-text-[14px] tw-leading-[14px] tw-font-[400]"
114
+ data-target="{{ block.settings.module_name }}"
115
+ >{{ block.settings.text }}</span>
116
+
117
+ </div>
118
+ {% unless forloop.last %}
119
+ <div class="pc-tab-item-last tw-w-[1px] tw-h-[16px] tw-bg-[#9E9E9E]">&nbsp;</div>
120
+ {% endunless %}
121
+ {% endfor %}
122
+ </div>
123
+ <div class="tw-flex-shrink-0 tw-relative">
124
+ <div class="cover-box tw-absolute tw-top-0 tw-left-[-50px] tw-w-[50px] tw-h-full">&nbsp;</div>
125
+ {% render 'zz-button',
126
+ href: section.settings.url,
127
+ type: 'primary',
128
+ color: 'white',
129
+ text: section.settings.btn_text,
130
+ size: 'medium',
131
+ class_name: btn_class
132
+
133
+ %}
134
+ </div>
135
+
136
+
137
+ </div>
138
+ </div>
139
+
140
+ <div class="zz-navigation-mobile-tab lg:tw-hidden tw-h-[52px] tw-flex tw-items-center tw-justify-between tw-px-8">
141
+ <div class="mb-navigation-box-item zz-navigation-mb-item-box tw-flex tw-items-center tw-gap-[24px] tw-pr-[120px] tw-h-[52px] tw-overflow-x-scroll">
142
+ {% for block in section.blocks %}
143
+ <div class="pc-tab-item tw-flex-shrink-0">
144
+
145
+ <span
146
+ class="zz-navigation-tab-item-text tw-cursor-pointer tw-text-[#9E9E9E] tw-text-[13px] tw-leading-[13px] tw-font-[400]"
147
+ data-target="{{ block.settings.module_name }}"
148
+ >{{ block.settings.text }}</span>
149
+
150
+ </div>
151
+ {% endfor %}
152
+ </div>
153
+ <div class="tw-flex-shrink-0 tw-relative">
154
+ <div class="cover-box tw-absolute tw-top-0 tw-left-[-40px] tw-w-[40px] tw-h-full">&nbsp;</div>
155
+ {% render 'zz-button',
156
+ href: section.settings.url,
157
+ type: 'primary',
158
+ color: 'white',
159
+ text: section.settings.btn_text,
160
+ size: 'small',
161
+ class_name: btn_class
162
+ %}
163
+ </div>
164
+ </div>
165
+
166
+ <script>
167
+ document.addEventListener('DOMContentLoaded', (event) => {
168
+ const isDesktop = window.innerWidth > 1024;
169
+
170
+ function scrollPaginationToCenter() {
171
+ // 获取当前section
172
+ const section = document.getElementById(
173
+ 'shopify-section-{{section.id}}'
174
+ );
175
+ const paginationContainer = isDesktop ? section.querySelector('.zz-navigation-pc-item-box') : section.querySelector('.zz-navigation-mb-item-box');
176
+ const activeBullet = paginationContainer.querySelector('.zz-navigation-active-text');
177
+
178
+ if (activeBullet) {
179
+ const containerWidth = paginationContainer.offsetWidth;
180
+ const bulletLeft = activeBullet.offsetLeft;
181
+ const bulletWidth = activeBullet.offsetWidth;
182
+
183
+ // 计算需要滚动的位置,使当前bullet居中
184
+ const scrollPosition = bulletLeft - (containerWidth / 2) + (bulletWidth / 2);
185
+
186
+ paginationContainer.scrollTo({
187
+ left: scrollPosition,
188
+ behavior: 'smooth'
189
+ });
190
+ }
191
+ }
192
+
193
+ const currentSection = document.getElementById(
194
+ 'shopify-section-{{section.id}}'
195
+ );
196
+ // 获取通知栏以及顶部弹窗 调整sticky的top。id="IPTipsBox",id="zz-quick-announcement-bar-container"
197
+ const iptipsBox = document.getElementById('IPTipsBox');
198
+ const pcDropdowns = document.querySelectorAll('.menu-wrapper');
199
+ const tabs = currentSection.querySelectorAll('.zz-navigation-tab-item-text');
200
+
201
+ const sections = document.querySelectorAll('[data-zz-module-name]');//document.querySelectorAll('.zz-navigation-moudule');
202
+ let showPcDropdowns = []
203
+ // 点击 tab 滚动
204
+ tabs.forEach(tab => {
205
+ tab.addEventListener('click', () => {
206
+ const id = tab.dataset.target;
207
+ const target = document.querySelector(`[data-zz-module-name="${id}"]`);
208
+ const headerHeight = isDesktop ? 64 : 44;
209
+ const offsetTop = target.offsetTop - headerHeight;
210
+ scrollPaginationToCenter();
211
+ window.scrollTo(0, offsetTop);
212
+ dataLayer.push({
213
+ event: "141_productpage_click_header_tab_item",
214
+ timestamp: new Date().toISOString(),
215
+ header_module_name: id,
216
+ });
217
+ });
218
+ });
219
+
220
+ // 监听滚动,高亮 tab
221
+ const observerOptions = {
222
+ root: null,
223
+ rootMargin: '0px 0px 0px 0px',
224
+ threshold: 0.1
225
+ };
226
+
227
+ const observer = new IntersectionObserver(entries => {
228
+ entries.forEach(entry => {
229
+ if (entry.isIntersecting) {
230
+ const id = entry.target.dataset.zzModuleName;
231
+ tabs.forEach(tab => {
232
+ tab.classList.toggle('zz-navigation-active-text', tab.dataset.target === id);
233
+ scrollPaginationToCenter();
234
+
235
+ });
236
+ }
237
+
238
+ });
239
+ }, observerOptions);
240
+ const headerObserver = new IntersectionObserver(entries => {
241
+ entries.forEach(entry => {
242
+ if (entry.target == iptipsBox) {
243
+
244
+ if (entry.isIntersecting) {
245
+ // 计算iptipsBox的高度,并设置sticky的top
246
+ const iptipsBoxHeight = entry.target.offsetHeight;
247
+ if(isDesktop) {
248
+ currentSection.style.top = iptipsBoxHeight + 'px';
249
+ } else {
250
+ // 后期移动端要加上导航栏的高度 44
251
+ currentSection.style.top = iptipsBoxHeight + 44 + 'px';
252
+ }
253
+
254
+ } else {
255
+
256
+ if(isDesktop) {
257
+ currentSection.style.top = '0px';
258
+ } else {
259
+ currentSection.style.top = '44px';
260
+ }
261
+ }
262
+ } else {
263
+ if(entry.isIntersecting) {
264
+ if(!showPcDropdowns.includes(entry.target)) {
265
+ showPcDropdowns.push(entry.target);
266
+ }
267
+ } else {
268
+ showPcDropdowns = showPcDropdowns.filter(dropdown => dropdown !== entry.target);
269
+ }
270
+ if(isDesktop) {
271
+ if(showPcDropdowns.length > 0) {
272
+ currentSection.style.zIndex = '490';
273
+ } else {
274
+ currentSection.style.zIndex = '501';
275
+ }
276
+ }
277
+ }
278
+
279
+ });
280
+ }, {
281
+ root: null,
282
+ rootMargin: '0px 0px 0px 0px',
283
+ threshold: 0
284
+ });
285
+
286
+
287
+ sections.forEach(section => observer.observe(section));
288
+ headerObserver.observe(iptipsBox);
289
+ pcDropdowns.forEach(dropdown => headerObserver.observe(dropdown));
290
+ function handlePCTouchScroll () {
291
+ const el = document.querySelector('.zz-navigation-pc-item-box');
292
+ let isDown = false;
293
+ let startX, scrollLeft;
294
+
295
+ el.addEventListener('mousedown', e => {
296
+ isDown = true;
297
+ el.classList.add('dragging');
298
+ startX = e.pageX;
299
+ scrollLeft = el.scrollLeft;
300
+ });
301
+
302
+ el.addEventListener('mouseleave', () => isDown = false);
303
+ el.addEventListener('mouseup', () => isDown = false);
304
+ el.addEventListener('mousemove', e => {
305
+ if (!isDown) return;
306
+ e.preventDefault();
307
+ const x = e.pageX;
308
+ const walk = x - startX;
309
+ el.scrollLeft = scrollLeft - walk;
310
+ });
311
+
312
+ }
313
+ handlePCTouchScroll();
314
+
315
+ const btns = document.querySelectorAll('.{{ btn_class }}');
316
+ btns.forEach(btn => {
317
+ btn.addEventListener('click', (event) => {
318
+ dataLayer.push({
319
+ event: "{{ section.settings.buy_now_click_event_class_name }}",
320
+ timestamp: new Date().toISOString(),
321
+ });
322
+ });
323
+ {% if section.settings.btn_function_type == 'link_map' %}
324
+ if(window.bindSiteJump) {
325
+ bindSiteJump(btn, {{ section.settings.links | json }})
326
+ }
327
+ {% endif %}
328
+ })
329
+
330
+ })
331
+ </script>
332
+ <style>
333
+ #shopify-section-{{ section.id }} {
334
+ position: sticky;
335
+ width: 100%;
336
+ background-color: {{ section.settings.background_color }};
337
+ }
338
+
339
+ #shopify-section-{{ section.id }} .zz-navigation-mobile-tab {
340
+
341
+ }
342
+ #shopify-section-{{ section.id }} .zz-navigation-pc-tab {
343
+ width: 100%;
344
+ box-sizing: border-box;
345
+
346
+
347
+ }
348
+ #shopify-section-{{ section.id }} .cover-box {
349
+ background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, #000000 100%);
350
+
351
+ }
352
+ #shopify-section-{{ section.id }} .zz-navigation-active-text {
353
+ font-weight: 700;
354
+ color: #FFFFFF;
355
+ }
356
+ #shopify-section-{{ section.id }} .zz-navigation-mobile-tab {
357
+ border-bottom: 0.5px solid #FFFFFF26;
358
+ }
359
+ #shopify-section-{{ section.id }} .{{ btn_class }} {
360
+ flex-shrink: 0;
361
+ }
362
+ @media screen and (min-width: 1024px) {
363
+ #shopify-section-{{ section.id }} {
364
+ z-index: 501;
365
+ top: 0;
366
+ }
367
+
368
+ }
369
+ @media screen and (max-width: 1024px) {
370
+ #shopify-section-{{ section.id }} {
371
+ z-index: 499;
372
+ top: 44px;
373
+ }
374
+ #shopify-section-{{ section.id }} .{{ btn_class }} {
375
+ height: 28px;
376
+ padding: 0 16px;
377
+ }
378
+ }
379
+
380
+ .zz-navigation-pc-item-box {
381
+ overflow-x: auto;
382
+ overflow-y: hidden;
383
+ scrollbar-width: none; /* Firefox */
384
+ -ms-overflow-style: none; /* IE 10+ */
385
+ }
386
+ html {
387
+ scroll-behavior: auto;
388
+ }
389
+ .zz-navigation-pc-item-box::-webkit-scrollbar {
390
+ width: 0;
391
+ height: 0;
392
+ display: none; /* Chrome/Safari/Edge */
393
+ }
394
+ .zz-navigation-mb-item-box {
395
+ overflow-x: auto;
396
+ overflow-y: hidden;
397
+ scrollbar-width: none; /* Firefox */
398
+ -ms-overflow-style: none; /* IE 10+ */
399
+ }
400
+
401
+ .zz-navigation-mb-item-box::-webkit-scrollbar {
402
+ width: 0;
403
+ height: 0;
404
+ display: none; /* Chrome/Safari/Edge */
405
+ }
406
+
407
+
408
408
  </style>