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.
- package/CHANGELOG.md +21 -21
- package/README.md +56 -56
- package/assets/ScrollTrigger.min.js +11 -11
- package/assets/gsap.min.js +11 -11
- package/assets/jquery.js +2 -2
- package/assets/lazy-video.js +2 -2
- package/assets/lazyload.min.js +1 -1
- package/assets/lozad.js +10 -10
- package/assets/site-jump.js +52 -52
- package/assets/site-jumpV2.js +35 -35
- package/assets/swiper-bundle.min.css +12 -12
- package/assets/swiper-bundle.min.js +13 -13
- package/assets/swiper.css +330 -330
- package/assets/zz-components.css +322 -322
- package/assets/zz-components.js +166 -166
- package/assets/zz-fade-in-content.js +169 -169
- package/blocks/zz-accessories-item.liquid +188 -188
- package/blocks/zz-accessories-swiper.liquid +223 -223
- package/blocks/zz-button.liquid +216 -216
- package/blocks/zz-content-description-html.liquid +201 -201
- package/blocks/zz-content-description.liquid +209 -209
- package/blocks/zz-flex-layout-bg-block.liquid +524 -524
- package/blocks/zz-flex-layout-block.liquid +548 -548
- package/blocks/zz-flex-layout-widget.liquid +321 -321
- package/blocks/zz-full-screen-swiper.liquid +447 -447
- package/blocks/zz-icon.liquid +46 -46
- package/blocks/zz-mail.liquid +135 -135
- package/blocks/zz-mb-swiper-pc-flex.liquid +273 -273
- package/blocks/zz-price-tag-mini.liquid +100 -106
- package/blocks/zz-price-tag.liquid +41 -41
- package/blocks/zz-ratio-image.liquid +181 -181
- package/blocks/zz-ratio-video.liquid +115 -115
- package/blocks/zz-responsive-width-image.liquid +222 -222
- package/blocks/zz-responsive-width-video.liquid +166 -166
- package/blocks/zz-scroll-animate-bg-text.liquid +268 -268
- package/blocks/zz-scroll-cover.liquid +67 -67
- package/blocks/zz-tag.liquid +50 -50
- package/blocks/zz-text.liquid +227 -227
- package/blocks/zz-title.liquid +287 -287
- package/blocks/zz-video-button.liquid +84 -84
- package/blocks/zz-video-swiper-perview-item.liquid +221 -221
- package/blocks/zz-video-swiper-perview.liquid +585 -585
- package/component.config.json +7 -7
- package/package.json +1 -1
- package/scripts/postinstall-v1.js +39 -39
- package/scripts/postinstall-v2.js +47 -47
- package/scripts/postinstall-v3.js +51 -51
- package/scripts/publish-npm.js +43 -43
- package/sections/zz-flex-layout-section.liquid +269 -269
- package/sections/zz-navigation-tab-v3.liquid +407 -407
- package/sections/zz-navigation-tab.liquid +411 -411
- package/sections/zz-shopping-card-list.liquid +399 -399
- package/sections/zz-video-collapse-swiper.liquid +522 -522
- package/sections/zz-video-tab-swiper.liquid +748 -748
- package/snippets/zz-button.liquid +70 -70
- package/snippets/zz-content-h3.liquid +15 -15
- package/snippets/zz-content-text.liquid +56 -56
- package/snippets/zz-h2.liquid +31 -31
- package/snippets/zz-h3.liquid +31 -31
- package/snippets/zz-h4.liquid +30 -30
- package/snippets/zz-h5.liquid +39 -39
- package/snippets/zz-h6.liquid +39 -39
- package/snippets/zz-icon-next.liquid +17 -17
- package/snippets/zz-icon-prev.liquid +17 -17
- package/snippets/zz-icon.liquid +74 -74
- package/snippets/zz-img.liquid +44 -44
- package/snippets/zz-prev-next-btn.liquid +62 -62
- package/snippets/zz-price-tag.liquid +22 -22
- package/snippets/zz-spoke.liquid +142 -142
- package/snippets/zz-tag.liquid +22 -22
- package/snippets/zz-video-button.liquid +54 -54
- package/snippets/zz-video-md.liquid +117 -117
- package/snippets/zz-video.liquid +117 -117
|
@@ -1,268 +1,268 @@
|
|
|
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": "Scroll Animate BG Text"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"name": "滚动背景放大文字动画"
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
{% endschema %}
|
|
100
|
-
|
|
101
|
-
<div class="sticky-section">
|
|
102
|
-
<div class="image-container tw-relative tw-w-full tw-h-full">
|
|
103
|
-
<div class="zz-scroll-animate-bg-image tw-w-full tw-h-full">
|
|
104
|
-
{% render 'zz-img',
|
|
105
|
-
pc_image: block.settings.desktop_image,
|
|
106
|
-
mb_image: block.settings.mobile_image,
|
|
107
|
-
image_alt: block.settings.alt | escape,
|
|
108
|
-
class_name: 'tw-w-full tw-h-full tw-object-cover',
|
|
109
|
-
%}
|
|
110
|
-
|
|
111
|
-
</div>
|
|
112
|
-
|
|
113
|
-
<div class="text-overlay tw-absolute tw-w-full">
|
|
114
|
-
{% case block.settings.tag %}
|
|
115
|
-
{% when 'h2' %}
|
|
116
|
-
{% render 'zz-h2',
|
|
117
|
-
title: block.settings.pc_title,
|
|
118
|
-
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
119
|
-
title_color: block.settings.text_color,
|
|
120
|
-
|
|
121
|
-
class_name: 'scroll-animate-bg-title'
|
|
122
|
-
%}
|
|
123
|
-
{% when 'h3' %}
|
|
124
|
-
{% render 'zz-h3',
|
|
125
|
-
title: block.settings.pc_title,
|
|
126
|
-
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
127
|
-
title_color: block.settings.text_color,
|
|
128
|
-
class_name: 'scroll-animate-bg-title'
|
|
129
|
-
|
|
130
|
-
%}
|
|
131
|
-
{% when 'h4' %}
|
|
132
|
-
{% render 'zz-h4',
|
|
133
|
-
title: block.settings.pc_title,
|
|
134
|
-
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
135
|
-
title_color: block.settings.text_color,
|
|
136
|
-
class_name: 'scroll-animate-bg-title'
|
|
137
|
-
%}
|
|
138
|
-
{% when 'h5' %}
|
|
139
|
-
{% render 'zz-h5',
|
|
140
|
-
title: block.settings.pc_title,
|
|
141
|
-
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
142
|
-
title_color: block.settings.text_color,
|
|
143
|
-
class_name: 'scroll-animate-bg-title'
|
|
144
|
-
%}
|
|
145
|
-
{% endcase %}
|
|
146
|
-
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
<style>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
#shopify-block-{{ block.id }} {
|
|
160
|
-
height: 150vh;
|
|
161
|
-
width: 100%;
|
|
162
|
-
position: relative;
|
|
163
|
-
background-color: {{ block.settings.background_color }};
|
|
164
|
-
}
|
|
165
|
-
#shopify-block-{{ block.id }} .sticky-section {
|
|
166
|
-
position: sticky;
|
|
167
|
-
width: 100%;
|
|
168
|
-
top: 0;
|
|
169
|
-
height: 100vh;
|
|
170
|
-
}
|
|
171
|
-
#shopify-block-{{ block.id }} .scroll-animate-bg-title {
|
|
172
|
-
text-align: center;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@media screen and (max-width: 1023px) {
|
|
176
|
-
#shopify-block-{{ block.id }} {
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
#shopify-block-{{ block.id }} .text-overlay {
|
|
180
|
-
position: absolute;
|
|
181
|
-
top: {{ block.settings.mb_top }}%;
|
|
182
|
-
left: 50%;
|
|
183
|
-
transform: translateX(-50%);
|
|
184
|
-
opacity: 0;
|
|
185
|
-
transition: opacity 0.2s linear;
|
|
186
|
-
max-width: 90%;
|
|
187
|
-
pointer-events: none;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
@media screen and (min-width: 1024px) {
|
|
192
|
-
#shopify-block-{{ block.id }} {
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
#shopify-block-{{ block.id }} .text-overlay {
|
|
196
|
-
position: absolute;
|
|
197
|
-
top: 50%;
|
|
198
|
-
left: 50%;
|
|
199
|
-
transform: translate(-50%,-50%);
|
|
200
|
-
max-width: 70%;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
</style>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<script>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
document.addEventListener('DOMContentLoaded', function(){
|
|
212
|
-
const block = document.getElementById('shopify-block-{{ block.id }}');
|
|
213
|
-
const image = block.querySelector('.zz-scroll-animate-bg-image');
|
|
214
|
-
const text = block.querySelector('.text-overlay');
|
|
215
|
-
let scrollListener = null;
|
|
216
|
-
function clamp(v, min = 0, max = 1) {
|
|
217
|
-
return Math.max(min, Math.min(v, max));
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function updateOnScroll() {
|
|
221
|
-
console.log('updateOnScroll');
|
|
222
|
-
const rect = block.getBoundingClientRect();
|
|
223
|
-
const screenH = window.innerHeight;
|
|
224
|
-
const containerHeight = block.offsetHeight; // 150vh
|
|
225
|
-
|
|
226
|
-
// 滚动进度(0 ~ 150vh)
|
|
227
|
-
const scrollProgress = clamp(screenH - rect.top, 0, containerHeight);
|
|
228
|
-
|
|
229
|
-
// 1️⃣ scale 阶段:0 → 100vh
|
|
230
|
-
const scaleP = clamp(scrollProgress / screenH);
|
|
231
|
-
const scale = 0.6 + 0.4 * scaleP;
|
|
232
|
-
image.style.transform = `scale(${scale})`;
|
|
233
|
-
|
|
234
|
-
// 2️⃣ opacity 阶段:100vh → 150vh
|
|
235
|
-
const opacityP = clamp((scrollProgress - screenH) / (containerHeight - screenH));
|
|
236
|
-
text.style.opacity = opacityP;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// 创建 Intersection Observer 来监听 block 的可见性
|
|
240
|
-
const observer = new IntersectionObserver((entries) => {
|
|
241
|
-
entries.forEach(entry => {
|
|
242
|
-
if (entry.isIntersecting) {
|
|
243
|
-
// block 进入视口,添加 scroll 监听器
|
|
244
|
-
if (!scrollListener) {
|
|
245
|
-
scrollListener = updateOnScroll;
|
|
246
|
-
window.addEventListener('scroll', scrollListener);
|
|
247
|
-
window.addEventListener('resize', scrollListener);
|
|
248
|
-
console.log('Scroll listener added');
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
251
|
-
// block 离开视口,移除 scroll 监听器
|
|
252
|
-
if (scrollListener) {
|
|
253
|
-
window.removeEventListener('scroll', scrollListener);
|
|
254
|
-
window.removeEventListener('resize', scrollListener);
|
|
255
|
-
scrollListener = null;
|
|
256
|
-
console.log('Scroll listener removed');
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}, {
|
|
261
|
-
threshold: 0 // 只要有任何部分进入视口就触发
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
observer.observe(block);
|
|
265
|
-
updateOnScroll();
|
|
266
|
-
});
|
|
267
|
-
</script>
|
|
268
|
-
|
|
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": "Scroll Animate BG Text"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "滚动背景放大文字动画"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
{% endschema %}
|
|
100
|
+
|
|
101
|
+
<div class="sticky-section">
|
|
102
|
+
<div class="image-container tw-relative tw-w-full tw-h-full">
|
|
103
|
+
<div class="zz-scroll-animate-bg-image tw-w-full tw-h-full">
|
|
104
|
+
{% render 'zz-img',
|
|
105
|
+
pc_image: block.settings.desktop_image,
|
|
106
|
+
mb_image: block.settings.mobile_image,
|
|
107
|
+
image_alt: block.settings.alt | escape,
|
|
108
|
+
class_name: 'tw-w-full tw-h-full tw-object-cover',
|
|
109
|
+
%}
|
|
110
|
+
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<div class="text-overlay tw-absolute tw-w-full">
|
|
114
|
+
{% case block.settings.tag %}
|
|
115
|
+
{% when 'h2' %}
|
|
116
|
+
{% render 'zz-h2',
|
|
117
|
+
title: block.settings.pc_title,
|
|
118
|
+
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
119
|
+
title_color: block.settings.text_color,
|
|
120
|
+
|
|
121
|
+
class_name: 'scroll-animate-bg-title'
|
|
122
|
+
%}
|
|
123
|
+
{% when 'h3' %}
|
|
124
|
+
{% render 'zz-h3',
|
|
125
|
+
title: block.settings.pc_title,
|
|
126
|
+
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
127
|
+
title_color: block.settings.text_color,
|
|
128
|
+
class_name: 'scroll-animate-bg-title'
|
|
129
|
+
|
|
130
|
+
%}
|
|
131
|
+
{% when 'h4' %}
|
|
132
|
+
{% render 'zz-h4',
|
|
133
|
+
title: block.settings.pc_title,
|
|
134
|
+
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
135
|
+
title_color: block.settings.text_color,
|
|
136
|
+
class_name: 'scroll-animate-bg-title'
|
|
137
|
+
%}
|
|
138
|
+
{% when 'h5' %}
|
|
139
|
+
{% render 'zz-h5',
|
|
140
|
+
title: block.settings.pc_title,
|
|
141
|
+
title_mb: block.settings.mb_title | default: block.settings.pc_title,
|
|
142
|
+
title_color: block.settings.text_color,
|
|
143
|
+
class_name: 'scroll-animate-bg-title'
|
|
144
|
+
%}
|
|
145
|
+
{% endcase %}
|
|
146
|
+
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
<style>
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
#shopify-block-{{ block.id }} {
|
|
160
|
+
height: 150vh;
|
|
161
|
+
width: 100%;
|
|
162
|
+
position: relative;
|
|
163
|
+
background-color: {{ block.settings.background_color }};
|
|
164
|
+
}
|
|
165
|
+
#shopify-block-{{ block.id }} .sticky-section {
|
|
166
|
+
position: sticky;
|
|
167
|
+
width: 100%;
|
|
168
|
+
top: 0;
|
|
169
|
+
height: 100vh;
|
|
170
|
+
}
|
|
171
|
+
#shopify-block-{{ block.id }} .scroll-animate-bg-title {
|
|
172
|
+
text-align: center;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@media screen and (max-width: 1023px) {
|
|
176
|
+
#shopify-block-{{ block.id }} {
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
#shopify-block-{{ block.id }} .text-overlay {
|
|
180
|
+
position: absolute;
|
|
181
|
+
top: {{ block.settings.mb_top }}%;
|
|
182
|
+
left: 50%;
|
|
183
|
+
transform: translateX(-50%);
|
|
184
|
+
opacity: 0;
|
|
185
|
+
transition: opacity 0.2s linear;
|
|
186
|
+
max-width: 90%;
|
|
187
|
+
pointer-events: none;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
@media screen and (min-width: 1024px) {
|
|
192
|
+
#shopify-block-{{ block.id }} {
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
#shopify-block-{{ block.id }} .text-overlay {
|
|
196
|
+
position: absolute;
|
|
197
|
+
top: 50%;
|
|
198
|
+
left: 50%;
|
|
199
|
+
transform: translate(-50%,-50%);
|
|
200
|
+
max-width: 70%;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
</style>
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
<script>
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
document.addEventListener('DOMContentLoaded', function(){
|
|
212
|
+
const block = document.getElementById('shopify-block-{{ block.id }}');
|
|
213
|
+
const image = block.querySelector('.zz-scroll-animate-bg-image');
|
|
214
|
+
const text = block.querySelector('.text-overlay');
|
|
215
|
+
let scrollListener = null;
|
|
216
|
+
function clamp(v, min = 0, max = 1) {
|
|
217
|
+
return Math.max(min, Math.min(v, max));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function updateOnScroll() {
|
|
221
|
+
console.log('updateOnScroll');
|
|
222
|
+
const rect = block.getBoundingClientRect();
|
|
223
|
+
const screenH = window.innerHeight;
|
|
224
|
+
const containerHeight = block.offsetHeight; // 150vh
|
|
225
|
+
|
|
226
|
+
// 滚动进度(0 ~ 150vh)
|
|
227
|
+
const scrollProgress = clamp(screenH - rect.top, 0, containerHeight);
|
|
228
|
+
|
|
229
|
+
// 1️⃣ scale 阶段:0 → 100vh
|
|
230
|
+
const scaleP = clamp(scrollProgress / screenH);
|
|
231
|
+
const scale = 0.6 + 0.4 * scaleP;
|
|
232
|
+
image.style.transform = `scale(${scale})`;
|
|
233
|
+
|
|
234
|
+
// 2️⃣ opacity 阶段:100vh → 150vh
|
|
235
|
+
const opacityP = clamp((scrollProgress - screenH) / (containerHeight - screenH));
|
|
236
|
+
text.style.opacity = opacityP;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 创建 Intersection Observer 来监听 block 的可见性
|
|
240
|
+
const observer = new IntersectionObserver((entries) => {
|
|
241
|
+
entries.forEach(entry => {
|
|
242
|
+
if (entry.isIntersecting) {
|
|
243
|
+
// block 进入视口,添加 scroll 监听器
|
|
244
|
+
if (!scrollListener) {
|
|
245
|
+
scrollListener = updateOnScroll;
|
|
246
|
+
window.addEventListener('scroll', scrollListener);
|
|
247
|
+
window.addEventListener('resize', scrollListener);
|
|
248
|
+
console.log('Scroll listener added');
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
// block 离开视口,移除 scroll 监听器
|
|
252
|
+
if (scrollListener) {
|
|
253
|
+
window.removeEventListener('scroll', scrollListener);
|
|
254
|
+
window.removeEventListener('resize', scrollListener);
|
|
255
|
+
scrollListener = null;
|
|
256
|
+
console.log('Scroll listener removed');
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}, {
|
|
261
|
+
threshold: 0 // 只要有任何部分进入视口就触发
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
observer.observe(block);
|
|
265
|
+
updateOnScroll();
|
|
266
|
+
});
|
|
267
|
+
</script>
|
|
268
|
+
|
|
@@ -1,67 +1,67 @@
|
|
|
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": "Scroll Cover Block"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "滚动覆盖视图切换",
|
|
25
|
-
},
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
{% endschema %}
|
|
29
|
-
|
|
30
|
-
<style>
|
|
31
|
-
#shopify-block-{{ block.id }} .zz-scroll-cover-block-container {
|
|
32
|
-
width: 100%;
|
|
33
|
-
position: relative;
|
|
34
|
-
height: 200vh;
|
|
35
|
-
}
|
|
36
|
-
#shopify-block-{{ block.id }} .zz-scroll-cover-sticky-box {
|
|
37
|
-
position: sticky;
|
|
38
|
-
top: 0;
|
|
39
|
-
height: 100vh;
|
|
40
|
-
z-index: 10;
|
|
41
|
-
}
|
|
42
|
-
#shopify-block-{{ block.id }} .zz-scroll-cover-absolute-box {
|
|
43
|
-
position: absolute;
|
|
44
|
-
top: 100vh;
|
|
45
|
-
height: 100vh;
|
|
46
|
-
width: 100%;
|
|
47
|
-
z-index: 11;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
</style>
|
|
51
|
-
|
|
52
|
-
<div class="zz-scroll-cover-block-container">
|
|
53
|
-
{% content_for 'blocks' %}
|
|
54
|
-
</div>
|
|
55
|
-
<script>
|
|
56
|
-
const block = document.getElementById('shopify-block-{{ block.id }}');
|
|
57
|
-
const container = block.querySelector('.zz-scroll-cover-block-container');
|
|
58
|
-
const subBlcoks = container.querySelectorAll(':scope > div');
|
|
59
|
-
// 给每个 swiper-slide 添加 class swiper-slide
|
|
60
|
-
subBlcoks.forEach((block,index) => {
|
|
61
|
-
if(index === 0){
|
|
62
|
-
block.classList.add('zz-scroll-cover-sticky-box');
|
|
63
|
-
} else {
|
|
64
|
-
block.classList.add('zz-scroll-cover-absolute-box');
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
</script>
|
|
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": "Scroll Cover Block"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "滚动覆盖视图切换",
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
{% endschema %}
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
#shopify-block-{{ block.id }} .zz-scroll-cover-block-container {
|
|
32
|
+
width: 100%;
|
|
33
|
+
position: relative;
|
|
34
|
+
height: 200vh;
|
|
35
|
+
}
|
|
36
|
+
#shopify-block-{{ block.id }} .zz-scroll-cover-sticky-box {
|
|
37
|
+
position: sticky;
|
|
38
|
+
top: 0;
|
|
39
|
+
height: 100vh;
|
|
40
|
+
z-index: 10;
|
|
41
|
+
}
|
|
42
|
+
#shopify-block-{{ block.id }} .zz-scroll-cover-absolute-box {
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: 100vh;
|
|
45
|
+
height: 100vh;
|
|
46
|
+
width: 100%;
|
|
47
|
+
z-index: 11;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
</style>
|
|
51
|
+
|
|
52
|
+
<div class="zz-scroll-cover-block-container">
|
|
53
|
+
{% content_for 'blocks' %}
|
|
54
|
+
</div>
|
|
55
|
+
<script>
|
|
56
|
+
const block = document.getElementById('shopify-block-{{ block.id }}');
|
|
57
|
+
const container = block.querySelector('.zz-scroll-cover-block-container');
|
|
58
|
+
const subBlcoks = container.querySelectorAll(':scope > div');
|
|
59
|
+
// 给每个 swiper-slide 添加 class swiper-slide
|
|
60
|
+
subBlcoks.forEach((block,index) => {
|
|
61
|
+
if(index === 0){
|
|
62
|
+
block.classList.add('zz-scroll-cover-sticky-box');
|
|
63
|
+
} else {
|
|
64
|
+
block.classList.add('zz-scroll-cover-absolute-box');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
</script>
|