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.
Files changed (61) hide show
  1. package/README.md +12 -0
  2. package/assets/fade-in-content.js +169 -0
  3. package/assets/gsap.min.js +11 -0
  4. package/assets/http-request.js +73 -0
  5. package/assets/jquery.js +2 -0
  6. package/assets/lozad.js +10 -0
  7. package/assets/site-jump.js +52 -0
  8. package/assets/site-jumpV2.js +35 -0
  9. package/assets/swiper-bundle.min.css +13 -0
  10. package/assets/swiper-bundle.min.js +14 -0
  11. package/assets/swiper.css +331 -0
  12. package/assets/zz-components.css +323 -0
  13. package/assets/zz-components.js +166 -0
  14. package/blocks/zz-accessories-item.liquid +183 -0
  15. package/blocks/zz-accessories-swiper.liquid +223 -0
  16. package/blocks/zz-button.liquid +189 -0
  17. package/blocks/zz-content-description-html.liquid +199 -0
  18. package/blocks/zz-content-description.liquid +200 -0
  19. package/blocks/zz-flex-layout-bg-block.liquid +520 -0
  20. package/blocks/zz-flex-layout-block.liquid +545 -0
  21. package/blocks/zz-flex-layout-widget.liquid +318 -0
  22. package/blocks/zz-full-screen-swiper.liquid +444 -0
  23. package/blocks/zz-icon.liquid +46 -0
  24. package/blocks/zz-mail.liquid +135 -0
  25. package/blocks/zz-mb-swiper-pc-flex.liquid +270 -0
  26. package/blocks/zz-ratio-image.liquid +177 -0
  27. package/blocks/zz-ratio-video.liquid +112 -0
  28. package/blocks/zz-responsive-width-image.liquid +219 -0
  29. package/blocks/zz-responsive-width-video.liquid +163 -0
  30. package/blocks/zz-scroll-animate-bg-text.liquid +265 -0
  31. package/blocks/zz-scroll-cover.liquid +64 -0
  32. package/blocks/zz-tag.liquid +48 -0
  33. package/blocks/zz-text.liquid +225 -0
  34. package/blocks/zz-title.liquid +284 -0
  35. package/blocks/zz-video-button.liquid +81 -0
  36. package/blocks/zz-video-swiper-perview-item.liquid +216 -0
  37. package/blocks/zz-video-swiper-perview.liquid +582 -0
  38. package/component.config.json +4 -0
  39. package/package.json +23 -0
  40. package/scripts/postinstall-v2.js +47 -0
  41. package/scripts/postinstall.js +39 -0
  42. package/sections/zz-flex-layout-section.liquid +266 -0
  43. package/sections/zz-navigation-tab-v3.liquid +403 -0
  44. package/sections/zz-navigation-tab.liquid +410 -0
  45. package/sections/zz-video-collapse-swiper.liquid +522 -0
  46. package/sections/zz-video-tab-swiper.liquid +745 -0
  47. package/snippets/zz-button.liquid +70 -0
  48. package/snippets/zz-content-text.liquid +56 -0
  49. package/snippets/zz-h2.liquid +31 -0
  50. package/snippets/zz-h3.liquid +31 -0
  51. package/snippets/zz-h4.liquid +30 -0
  52. package/snippets/zz-h5.liquid +39 -0
  53. package/snippets/zz-h6.liquid +39 -0
  54. package/snippets/zz-icon.liquid +74 -0
  55. package/snippets/zz-img.liquid +44 -0
  56. package/snippets/zz-prev-next-btn.liquid +62 -0
  57. package/snippets/zz-spoke.liquid +142 -0
  58. package/snippets/zz-tag.liquid +22 -0
  59. package/snippets/zz-video-button.liquid +55 -0
  60. package/snippets/zz-video-md.liquid +117 -0
  61. package/snippets/zz-video.liquid +117 -0
@@ -0,0 +1,219 @@
1
+ {% schema %}
2
+ {
3
+ "name": "Responsive Width Image",
4
+ "class": "responsive-width-image",
5
+ "settings": [
6
+ {
7
+ "type": "header",
8
+ "content": "PC端设置"
9
+ },
10
+ {
11
+ "type": "image_picker",
12
+ "id": "desktop_image",
13
+ "label": "PC端图片"
14
+ },
15
+ {
16
+ "type": "number",
17
+ "id": "desktop_width_xl",
18
+ "label": "PC端宽度 大屏xl屏幕",
19
+ "default": 800,
20
+ "info": "单位:px"
21
+ },
22
+ {
23
+ "type": "number",
24
+ "id": "desktop_width_lg",
25
+ "label": "PC端宽度 中等屏lg屏幕",
26
+ "default": 600,
27
+ "info": "单位:px"
28
+ },
29
+ {
30
+ "type": "number",
31
+ "id": "desktop_border_radius",
32
+ "label": "PC端圆角",
33
+ "default": 16,
34
+ "info": "单位:px"
35
+ },
36
+ {
37
+ "type": "header",
38
+ "content": "移动端设置"
39
+ },
40
+ {
41
+ "type": "image_picker",
42
+ "id": "mobile_image",
43
+ "label": "移动端图片"
44
+ },
45
+ {
46
+ "type": "select",
47
+ "id": "mb_width_type",
48
+ "label": "移动端宽度类型",
49
+ "options": [
50
+ { "value": "mb_use_padding", "label": "使用内边距限制" },
51
+ { "value": "mb_use_parent_ratio", "label": "父级比例限制" },
52
+ { "value": "mb_use_width_px", "label": "宽度限制PX" }
53
+ ],
54
+ "default": "mb_use_padding"
55
+ },
56
+ {
57
+ "type": "number",
58
+ "id": "mobile_padding_x",
59
+ "label": "移动端左右内边距",
60
+ "default": 0,
61
+ "info": "单位:px",
62
+ "visible_if": "{{ block.settings.mb_width_type == 'mb_use_padding' }}"
63
+ },
64
+ {
65
+ "type": "range",
66
+ "id": "mobile_width",
67
+ "min": 0,
68
+ "max": 100,
69
+ "step": 1,
70
+ "unit": "%",
71
+ "label": "移动端占父容器的百分比,单位%",
72
+ "default": 100,
73
+ "visible_if": "{{ block.settings.mb_width_type == 'mb_use_parent_ratio' }}"
74
+ },
75
+ {
76
+ "type": "number",
77
+ "id": "mb_width_px",
78
+ "label": "移动端宽度 宽度限制PX",
79
+ "default": 100,
80
+ "info": "单位:px",
81
+ "visible_if": "{{ block.settings.mb_width_type == 'mb_use_width_px' }}"
82
+ },
83
+ {
84
+ "type": "number",
85
+ "id": "mobile_border_radius",
86
+ "label": "移动端圆角",
87
+ "default": 10,
88
+ "info": "单位:px"
89
+ },
90
+ {
91
+ "type": "text",
92
+ "id": "alt",
93
+ "label": "alt",
94
+ "default": "image loading"
95
+ },
96
+ {
97
+ "type": "checkbox",
98
+ "id": "has_link",
99
+ "label": "是否有链接",
100
+ "default": false
101
+ },
102
+ {
103
+ "type": "select",
104
+ "id": "function_type",
105
+ "label": "功能类型",
106
+ "options": [
107
+ {
108
+ "value": "link",
109
+ "label": "链接"
110
+ },
111
+ {
112
+ "value": "link_map",
113
+ "label": "多国家映射"
114
+ },
115
+ ],
116
+ "default": "link",
117
+ "visible_if": "{{ block.settings.has_link == true }}"
118
+ },
119
+ {
120
+ "type": "url",
121
+ "id": "url",
122
+ "label": "链接",
123
+ "visible_if": "{{ block.settings.function_type == 'link' and block.settings.has_link == true }}"
124
+ },
125
+ {
126
+ "type": "textarea",
127
+ "id": "links",
128
+ "label": "Sites Link Map",
129
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
130
+ "visible_if": "{{ block.settings.function_type == 'link_map' and block.settings.has_link == true }}"
131
+ },
132
+ ],
133
+ "presets": [
134
+ {
135
+ "name": "宽度响应式图片",
136
+
137
+ }
138
+ ]
139
+ }
140
+ {% endschema %}
141
+
142
+ {% assign image_class = 'zz-link-' | append: block.id %}
143
+
144
+ <div class="responsive-width-container tw-w-full tw-box-border {{ image_class }}">
145
+ {% render 'zz-img',
146
+ pc_image: block.settings.desktop_image,
147
+ mb_image: block.settings.mobile_image,
148
+ image_alt: block.settings.alt | escape,
149
+ class_name: 'responsive-width-image',
150
+ %}
151
+
152
+
153
+ </div>
154
+
155
+
156
+ <style>
157
+
158
+ #shopify-block-{{ block.id }} .responsive-width-container {
159
+ box-sizing: border-box;
160
+ overflow: hidden;
161
+ {% if block.settings.has_link %}
162
+ cursor: pointer;
163
+ {% endif %}
164
+
165
+ }
166
+
167
+ @media screen and (max-width: 1023px) {
168
+ #shopify-block-{{ block.id }} {
169
+ {% if block.settings.mb_width_type == 'mb_use_padding' %}
170
+ width: 100%;
171
+ {% elsif block.settings.mb_width_type == 'mb_use_parent_ratio' %}
172
+ width: {{ block.settings.mobile_width }}%
173
+ {% elsif block.settings.mb_width_type == 'mb_use_width_px' %}
174
+ width: {{ block.settings.mb_width_px }}px;
175
+ {% endif %}
176
+
177
+ }
178
+ #shopify-block-{{ block.id }} .responsive-width-container {
179
+ border-radius: {{ block.settings.mobile_border_radius }}px;
180
+ {% if block.settings.mb_width_type == 'mb_use_padding' %}
181
+ padding: 0 {{ block.settings.mobile_padding_x }}px;
182
+ {% endif %}
183
+ }
184
+
185
+ }
186
+ @media screen and (min-width: 1024px) {
187
+ #shopify-block-{{ block.id }} .responsive-width-container {
188
+ padding: 0px;
189
+ width: {{ block.settings.desktop_width_lg }}px;
190
+ border-radius: {{ block.settings.desktop_border_radius }}px;
191
+ }
192
+ }
193
+ @media screen and (min-width: 1280px) {
194
+ #shopify-block-{{ block.id }} .responsive-width-container {
195
+ width: {{ block.settings.desktop_width_xl }}px;
196
+ }
197
+ }
198
+
199
+ </style>
200
+
201
+ {% if block.settings.has_link %}
202
+ <script>
203
+ document.addEventListener('DOMContentLoaded', (event) => {
204
+ const btn = document.getElementsByClassName('{{ image_class }}')
205
+ if(btn && btn[0]) {
206
+ {% if block.settings.function_type == 'link_map' %}
207
+ bindSiteJump(btn[0], {{ block.settings.links | json }})
208
+ {% else %}
209
+ // 监听点击事件
210
+ btn[0].addEventListener('click', (event) => {
211
+ event.preventDefault();
212
+ window.location.href = '{{ block.settings.url }}';
213
+ })
214
+ {% endif %}
215
+ }
216
+
217
+ })
218
+ </script>
219
+ {% endif %}
@@ -0,0 +1,163 @@
1
+ {% schema %}
2
+ {
3
+ "name": "Responsive Width Video",
4
+ "class": "responsive-width-video",
5
+ "settings": [
6
+ {
7
+ "type": "header",
8
+ "content": "PC端设置"
9
+ },
10
+ {
11
+ "type": "text",
12
+ "id": "video_url_pc",
13
+ "label": "Video url PC",
14
+ "info": "使用cdn视频时,填写视频url。防止大屏幕视频模糊"
15
+ },
16
+ {
17
+ "type": "video",
18
+ "id": "video_pc",
19
+ "label": "PC端视频"
20
+ },
21
+ {
22
+ "type": "image_picker",
23
+ "id": "poster_pc",
24
+ "label": "PC端视频 封面"
25
+ },
26
+
27
+ {
28
+ "type": "number",
29
+ "id": "desktop_width_xl",
30
+ "label": "PC端宽度 大屏xl屏幕",
31
+ "default": 800,
32
+ "info": "单位:px"
33
+ },
34
+ {
35
+ "type": "number",
36
+ "id": "desktop_width_lg",
37
+ "label": "PC端宽度 中等屏lg屏幕",
38
+ "default": 600,
39
+ "info": "单位:px"
40
+ },
41
+ {
42
+ "type": "number",
43
+ "id": "desktop_border_radius",
44
+ "label": "PC端圆角",
45
+ "default": 16,
46
+ "info": "单位:px"
47
+ },
48
+ {
49
+ "type": "header",
50
+ "content": "移动端设置"
51
+ },
52
+ {
53
+ "type": "video",
54
+ "id": "video_mb",
55
+ "label": "移动端视频"
56
+ },
57
+ {
58
+ "type": "image_picker",
59
+ "id": "poster_mb",
60
+ "label": "移动端视频封面"
61
+ },
62
+ {
63
+ "type": "checkbox",
64
+ "id": "mb_use_padding",
65
+ "label": "是否使用内边距限制宽度",
66
+ "default": true
67
+ },
68
+ {
69
+ "type": "number",
70
+ "id": "mobile_padding_x",
71
+ "label": "移动端左右内边距",
72
+ "default": 0,
73
+ "info": "单位:px",
74
+ "visible_if": "{{ block.settings.mb_use_padding == true }}"
75
+ },
76
+ {
77
+ "type": "range",
78
+ "id": "mobile_width",
79
+ "min": 0,
80
+ "max": 100,
81
+ "step": 1,
82
+ "unit": "%",
83
+ "label": "移动端占父容器的百分比,单位%",
84
+ "default": 100,
85
+ "visible_if": "{{ block.settings.mb_use_padding == false }}"
86
+ },
87
+ {
88
+ "type": "number",
89
+ "id": "mobile_border_radius",
90
+ "label": "移动端圆角",
91
+ "default": 10,
92
+ "info": "单位:px"
93
+ },
94
+
95
+ ],
96
+ "presets": [
97
+ {
98
+ "name": "宽度响应式视频",
99
+
100
+ }
101
+ ]
102
+ }
103
+ {% endschema %}
104
+
105
+
106
+ <div class="content-video-container tw-box-border tw-overflow-hidden">
107
+ {% if block.settings.video_url_pc != blank %}
108
+ {% assign pc_video = block.settings.video_url_pc %}
109
+ {% else %}
110
+ {% assign pc_video = block.settings.video_pc %}
111
+ {% endif %}
112
+ {% render 'zz-video',
113
+ pc_video: pc_video,
114
+ pc_poster: block.settings.poster_pc,
115
+ mb_video: block.settings.video_mb,
116
+ mb_poster: block.settings.poster_mb,
117
+ lazy: true,
118
+ class: 'tw-w-full tw-h-auto',
119
+ autoplay: true,
120
+ loop: true,
121
+ muted: true
122
+ %}
123
+
124
+ </div>
125
+
126
+
127
+ <style>
128
+
129
+ #shopify-block-{{ block.id }} .content-video-container {
130
+ box-sizing: border-box;
131
+ overflow: hidden;
132
+ }
133
+
134
+ @media screen and (max-width: 1023px) {
135
+ #shopify-block-{{ block.id }} {
136
+ {% if block.settings.mb_use_padding %}
137
+ width: 100%;
138
+ {% else %}
139
+ width: {{ block.settings.mobile_width }}%
140
+ {% endif %}
141
+ }
142
+ #shopify-block-{{ block.id }} .content-video-container {
143
+ border-radius: {{ block.settings.mobile_border_radius }}px;
144
+ {% if block.settings.mb_use_padding %}
145
+ padding: 0 {{ block.settings.mobile_padding_x }}px;
146
+ {% endif %}
147
+ }
148
+
149
+ }
150
+ @media screen and (min-width: 1024px) {
151
+ #shopify-block-{{ block.id }} .content-video-container {
152
+ padding: 0px;
153
+ width: {{ block.settings.desktop_width_lg }}px;
154
+ border-radius: {{ block.settings.desktop_border_radius }}px;
155
+ }
156
+ }
157
+ @media screen and (min-width: 1280px) {
158
+ #shopify-block-{{ block.id }} .content-video-container {
159
+ width: {{ block.settings.desktop_width_xl }}px;
160
+ }
161
+ }
162
+
163
+ </style>
@@ -0,0 +1,265 @@
1
+ {% schema %}
2
+ {
3
+ "name": "scroll animate bg text",
4
+ "class": "scroll-animate-bg-text",
5
+ "settings": [
6
+ {
7
+ "type": "color_background",
8
+ "id": "background_color",
9
+ "label": "背景颜色",
10
+ "default": "rgba(0,0,0,0)"
11
+ },
12
+ {
13
+ "type": "image_picker",
14
+ "id": "desktop_image",
15
+ "label": "PC端图片"
16
+ },
17
+
18
+ {
19
+ "type": "image_picker",
20
+ "id": "mobile_image",
21
+ "label": "移动端图片"
22
+ },
23
+ {
24
+ "type": "richtext",
25
+ "id": "pc_title",
26
+ "label": "PC标题内容 (PC Title Content)",
27
+ "default": "<p>这里是标题</p>"
28
+ },
29
+ {
30
+ "type": "richtext",
31
+ "id": "mb_title",
32
+ "label": "移动标题内容 (Mobile Title Content)",
33
+
34
+ },
35
+ {
36
+ "type": "select",
37
+ "id": "tag",
38
+ "label": "标题等级 (Heading Tag)",
39
+ "options": [
40
+ { "value": "h2", "label": "二级标题 (H2)" },
41
+ { "value": "h3", "label": "三级标题 (H3)" },
42
+ { "value": "h4", "label": "四级标题 (H4)" },
43
+ { "value": "h5", "label": "五级标题 (H5)" },
44
+ ],
45
+ "default": "h2"
46
+ },
47
+
48
+ {
49
+ "type": "select",
50
+ "id": "pc_align",
51
+ "label": "标题 PC对齐方式",
52
+ "options": [
53
+ { "value": "left", "label": "左对齐 (Left)" },
54
+ { "value": "center", "label": "居中对齐 (Center)" },
55
+ { "value": "right", "label": "右对齐 (Right)" }
56
+ ],
57
+ "default": "center"
58
+ },
59
+ {
60
+ "type": "select",
61
+ "id": "mobile_align",
62
+ "label": "标题 移动对齐方式",
63
+ "options": [
64
+ { "value": "left", "label": "左对齐 (Left)" },
65
+ { "value": "center", "label": "居中对齐 (Center)" },
66
+ { "value": "right", "label": "右对齐 (Right)" }
67
+ ],
68
+ "default": "center"
69
+ },
70
+ {
71
+ "type": "range",
72
+ "id": "mb_top",
73
+ "min": 0,
74
+ "max": 100,
75
+ "step": 1,
76
+ "unit": "%",
77
+ "label": "移动端标题距离顶部高度百分比,单位%",
78
+ "default": 20
79
+ },
80
+
81
+ {
82
+ "type": "color",
83
+ "id": "text_color",
84
+ "label": "文字颜色",
85
+ "default": "#000000"
86
+ },
87
+
88
+
89
+ ],
90
+ "presets": [
91
+ {
92
+ "name": "滚动背景放大文字动画"
93
+ }
94
+ ]
95
+ }
96
+ {% endschema %}
97
+
98
+ <div class="sticky-section">
99
+ <div class="image-container tw-relative tw-w-full tw-h-full">
100
+ <div class="zz-scroll-animate-bg-image tw-w-full tw-h-full">
101
+ {% render 'zz-img',
102
+ pc_image: block.settings.desktop_image,
103
+ mb_image: block.settings.mobile_image,
104
+ image_alt: block.settings.alt | escape,
105
+ class_name: 'tw-w-full tw-h-full tw-object-cover',
106
+ %}
107
+
108
+ </div>
109
+
110
+ <div class="text-overlay tw-absolute tw-w-full">
111
+ {% case block.settings.tag %}
112
+ {% when 'h2' %}
113
+ {% render 'zz-h2',
114
+ title: block.settings.pc_title,
115
+ title_mb: block.settings.mb_title | default: block.settings.pc_title,
116
+ title_color: block.settings.text_color,
117
+
118
+ class_name: 'scroll-animate-bg-title'
119
+ %}
120
+ {% when 'h3' %}
121
+ {% render 'zz-h3',
122
+ title: block.settings.pc_title,
123
+ title_mb: block.settings.mb_title | default: block.settings.pc_title,
124
+ title_color: block.settings.text_color,
125
+ class_name: 'scroll-animate-bg-title'
126
+
127
+ %}
128
+ {% when 'h4' %}
129
+ {% render 'zz-h4',
130
+ title: block.settings.pc_title,
131
+ title_mb: block.settings.mb_title | default: block.settings.pc_title,
132
+ title_color: block.settings.text_color,
133
+ class_name: 'scroll-animate-bg-title'
134
+ %}
135
+ {% when 'h5' %}
136
+ {% render 'zz-h5',
137
+ title: block.settings.pc_title,
138
+ title_mb: block.settings.mb_title | default: block.settings.pc_title,
139
+ title_color: block.settings.text_color,
140
+ class_name: 'scroll-animate-bg-title'
141
+ %}
142
+ {% endcase %}
143
+
144
+ </div>
145
+ </div>
146
+ </div>
147
+
148
+
149
+
150
+
151
+
152
+
153
+ <style>
154
+
155
+
156
+ #shopify-block-{{ block.id }} {
157
+ height: 150vh;
158
+ width: 100%;
159
+ position: relative;
160
+ background-color: {{ block.settings.background_color }};
161
+ }
162
+ #shopify-block-{{ block.id }} .sticky-section {
163
+ position: sticky;
164
+ width: 100%;
165
+ top: 0;
166
+ height: 100vh;
167
+ }
168
+ #shopify-block-{{ block.id }} .scroll-animate-bg-title {
169
+ text-align: center;
170
+ }
171
+
172
+ @media screen and (max-width: 1023px) {
173
+ #shopify-block-{{ block.id }} {
174
+
175
+ }
176
+ #shopify-block-{{ block.id }} .text-overlay {
177
+ position: absolute;
178
+ top: {{ block.settings.mb_top }}%;
179
+ left: 50%;
180
+ transform: translateX(-50%);
181
+ opacity: 0;
182
+ transition: opacity 0.2s linear;
183
+ max-width: 90%;
184
+ pointer-events: none;
185
+ }
186
+
187
+ }
188
+ @media screen and (min-width: 1024px) {
189
+ #shopify-block-{{ block.id }} {
190
+
191
+ }
192
+ #shopify-block-{{ block.id }} .text-overlay {
193
+ position: absolute;
194
+ top: 50%;
195
+ left: 50%;
196
+ transform: translate(-50%,-50%);
197
+ max-width: 70%;
198
+ }
199
+ }
200
+
201
+
202
+ </style>
203
+
204
+
205
+ <script>
206
+
207
+
208
+ document.addEventListener('DOMContentLoaded', function(){
209
+ const block = document.getElementById('shopify-block-{{ block.id }}');
210
+ const image = block.querySelector('.zz-scroll-animate-bg-image');
211
+ const text = block.querySelector('.text-overlay');
212
+ let scrollListener = null;
213
+ function clamp(v, min = 0, max = 1) {
214
+ return Math.max(min, Math.min(v, max));
215
+ }
216
+
217
+ function updateOnScroll() {
218
+ console.log('updateOnScroll');
219
+ const rect = block.getBoundingClientRect();
220
+ const screenH = window.innerHeight;
221
+ const containerHeight = block.offsetHeight; // 150vh
222
+
223
+ // 滚动进度(0 ~ 150vh)
224
+ const scrollProgress = clamp(screenH - rect.top, 0, containerHeight);
225
+
226
+ // 1️⃣ scale 阶段:0 → 100vh
227
+ const scaleP = clamp(scrollProgress / screenH);
228
+ const scale = 0.6 + 0.4 * scaleP;
229
+ image.style.transform = `scale(${scale})`;
230
+
231
+ // 2️⃣ opacity 阶段:100vh → 150vh
232
+ const opacityP = clamp((scrollProgress - screenH) / (containerHeight - screenH));
233
+ text.style.opacity = opacityP;
234
+ }
235
+
236
+ // 创建 Intersection Observer 来监听 block 的可见性
237
+ const observer = new IntersectionObserver((entries) => {
238
+ entries.forEach(entry => {
239
+ if (entry.isIntersecting) {
240
+ // block 进入视口,添加 scroll 监听器
241
+ if (!scrollListener) {
242
+ scrollListener = updateOnScroll;
243
+ window.addEventListener('scroll', scrollListener);
244
+ window.addEventListener('resize', scrollListener);
245
+ console.log('Scroll listener added');
246
+ }
247
+ } else {
248
+ // block 离开视口,移除 scroll 监听器
249
+ if (scrollListener) {
250
+ window.removeEventListener('scroll', scrollListener);
251
+ window.removeEventListener('resize', scrollListener);
252
+ scrollListener = null;
253
+ console.log('Scroll listener removed');
254
+ }
255
+ }
256
+ });
257
+ }, {
258
+ threshold: 0 // 只要有任何部分进入视口就触发
259
+ });
260
+
261
+ observer.observe(block);
262
+ updateOnScroll();
263
+ });
264
+ </script>
265
+
@@ -0,0 +1,64 @@
1
+ {% schema %}
2
+ {
3
+ "name": "Scroll Cover Block",
4
+ "class": "zz-scroll-cover-block",
5
+ "settings": [
6
+ {
7
+ "type": "color_background",
8
+ "id": "background_color",
9
+ "label": "背景颜色",
10
+ "default": "rgba(0,0,0,0)"
11
+ },
12
+
13
+ ],
14
+ "blocks": [
15
+ {
16
+ "type": "zz-flex-layout-bg-block",
17
+ }
18
+ ],
19
+ "presets": [
20
+ {
21
+ "name": "滚动覆盖视图切换",
22
+ },
23
+ ]
24
+ }
25
+ {% endschema %}
26
+
27
+ <style>
28
+ #shopify-block-{{ block.id }} .zz-scroll-cover-block-container {
29
+ width: 100%;
30
+ position: relative;
31
+ height: 200vh;
32
+ }
33
+ #shopify-block-{{ block.id }} .zz-scroll-cover-sticky-box {
34
+ position: sticky;
35
+ top: 0;
36
+ height: 100vh;
37
+ z-index: 10;
38
+ }
39
+ #shopify-block-{{ block.id }} .zz-scroll-cover-absolute-box {
40
+ position: absolute;
41
+ top: 100vh;
42
+ height: 100vh;
43
+ width: 100%;
44
+ z-index: 11;
45
+ }
46
+
47
+ </style>
48
+
49
+ <div class="zz-scroll-cover-block-container">
50
+ {% content_for 'blocks' %}
51
+ </div>
52
+ <script>
53
+ const block = document.getElementById('shopify-block-{{ block.id }}');
54
+ const container = block.querySelector('.zz-scroll-cover-block-container');
55
+ const subBlcoks = container.querySelectorAll(':scope > div');
56
+ // 给每个 swiper-slide 添加 class swiper-slide
57
+ subBlcoks.forEach((block,index) => {
58
+ if(index === 0){
59
+ block.classList.add('zz-scroll-cover-sticky-box');
60
+ } else {
61
+ block.classList.add('zz-scroll-cover-absolute-box');
62
+ }
63
+ });
64
+ </script>