zz-shopify-components 0.36.1-beta.8 → 0.36.1-beta.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.36.1-beta.8",
3
+ "version": "0.36.1-beta.9",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": [
6
6
  "shopify",
@@ -21,7 +21,7 @@
21
21
  >
22
22
  <div class="tw-box-border tw-mx-auto tw-max-w-[1220px] lg:tw-py-[80px] max-lg:tw-pt-[48px] max-lg:tw-pb-[30px]">
23
23
  {%- if section.settings.title != blank -%}
24
- <div class="tw-mb-[3rem] lg:tw-mb-[100px] tw-text-center tw-font-bold tw-text-[#2d2d2d] tw-leading-[1] tw-text-[2.8rem] lg:tw-text-[40px]">
24
+ <div class="tw-mb-[3rem] lg:tw-mb-[100px] max-lg:tw-px-[2rem] tw-text-center tw-font-bold tw-text-[#2d2d2d] tw-leading-[1] tw-text-[2.8rem] lg:tw-text-[40px]">
25
25
  {{ section.settings.title | escape }}
26
26
  </div>
27
27
  {%- endif -%}
@@ -190,15 +190,21 @@
190
190
 
191
191
  var isVisible = false;
192
192
  var ticking = false;
193
+ var lastNavOffset = -1;
193
194
 
194
- {%- comment -%} Height of the visible content-navigation bar (mobile vs pc) {%- endcomment -%}
195
- function getNavHeight() {
196
- var pc = document.querySelector('.content-navigation-pc');
197
- var mobile = document.querySelector('.content-navigation-mobile');
198
- {%- comment -%} the hidden one (wrong breakpoint) reports offsetHeight 0 {%- endcomment -%}
199
- var pcH = pc ? pc.offsetHeight : 0;
200
- var mobileH = mobile ? mobile.offsetHeight : 0;
201
- return Math.max(pcH, mobileH, 0);
195
+ {%- comment -%}
196
+ Offset of the floating head.
197
+ 没有 content-nagivation--visible 元素时贴顶 0px;
198
+ 存在时取导航条实际高度(PC / 移动端), 取不到则 PC 40px / 移动端 80px。
199
+ {%- endcomment -%}
200
+ function getNavOffset() {
201
+ var visibleNav = document.querySelector('.content-nagivation--visible');
202
+ if (!visibleNav) { return 0; }
203
+ var isDesktop = window.innerWidth > 1024;
204
+ var el = document.querySelector(isDesktop ? '.content-nagivation-pc' : '.content-nagivation-mobile');
205
+ var h = el ? el.offsetHeight : 0;
206
+ if (h) { return h; }
207
+ return isDesktop ? 40 : 80;
202
208
  }
203
209
 
204
210
  {%- comment -%} Match float bar geometry to the scroller (width, left, padding, column sizing) {%- endcomment -%}
@@ -209,7 +215,7 @@
209
215
  var padRight = parseFloat(cs.paddingRight) || 0;
210
216
 
211
217
  floatEl.style.left = scRect.left + 'px';
212
- floatEl.style.top = getNavHeight() + 'px';
218
+ floatEl.style.top = getNavOffset() + 'px';
213
219
  floatEl.style.width = scRect.width + 'px';
214
220
  floatInner.style.paddingLeft = padLeft + 'px';
215
221
  floatInner.style.paddingRight = padRight + 'px';
@@ -240,16 +246,23 @@
240
246
 
241
247
  function update() {
242
248
  ticking = false;
243
- var navH = getNavHeight();
249
+ var navOffset = getNavOffset();
244
250
  var headRect = header.getBoundingClientRect();
245
251
  var contentRect = content.getBoundingClientRect();
246
252
  var floatH = floatEl.offsetHeight || headRect.height;
247
253
 
248
254
  {%- comment -%} show once product row scrolls under the nav, hide when content bottom passes {%- endcomment -%}
249
- var shouldShow = headRect.bottom <= navH && contentRect.bottom > navH + floatH;
255
+ var shouldShow = headRect.bottom <= navOffset && contentRect.bottom > navOffset + floatH;
256
+
257
+ {%- comment -%} nav offset changed (navigation shown/hidden or breakpoint switch): re-sync {%- endcomment -%}
258
+ if (isVisible && navOffset !== lastNavOffset) {
259
+ lastNavOffset = navOffset;
260
+ syncLayout();
261
+ }
250
262
 
251
263
  if (shouldShow && !isVisible) {
252
264
  isVisible = true;
265
+ lastNavOffset = navOffset;
253
266
  syncLayout();
254
267
  syncScrollX();
255
268
  floatEl.classList.add('is-visible');
@@ -302,7 +315,7 @@
302
315
  {
303
316
  "type": "select",
304
317
  "id": "from_type",
305
- "label": "文案颜色模式",
318
+ "label": "价格前后缀",
306
319
  "default": "prefix",
307
320
  "options": [
308
321
  {
@@ -318,7 +331,7 @@
318
331
  {
319
332
  "type": "text",
320
333
  "id": "price_prefix",
321
- "label": "Price prefix suffix",
334
+ "label": "Price prefix",
322
335
  "default": "from"
323
336
  }
324
337
  ],