@vectoriox/iox-builder 1.4.26 → 1.4.27

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.
@@ -2139,13 +2139,17 @@ class StyleRegistryService {
2139
2139
  return `.${className} {\n${entries.join('\n')}\n}`;
2140
2140
  }
2141
2141
  /**
2142
- * Rewrite bare `vh` values to `calc(N * var(--preview-vh, 1vh))` so they
2143
- * resolve to the simulated viewport height in the builder canvas.
2144
- * In production (no --preview-vh defined) the fallback `1vh` preserves the
2145
- * original behaviour: `calc(50 * 1vh)` == `50vh`.
2142
+ * Rewrite viewport-relative units so they resolve to the simulated canvas
2143
+ * dimensions rather than the real browser viewport.
2144
+ *
2145
+ * --preview-vh / --preview-vw are set by BuilderComponent via ResizeObserver
2146
+ * and viewport-state subscription. In production (no variables defined) the
2147
+ * fallbacks `1vh` / `1vw` restore the original browser behaviour.
2146
2148
  */
2147
2149
  rewriteVh(value) {
2148
- return value.replace(/(-?\d*\.?\d+)vh/g, 'calc($1 * var(--preview-vh, 1vh))');
2150
+ return value
2151
+ .replace(/(-?\d*\.?\d+)vh/g, 'calc($1 * var(--preview-vh, 1vh))')
2152
+ .replace(/(-?\d*\.?\d+)vw/g, 'calc($1 * var(--preview-vw, 1vw))');
2149
2153
  }
2150
2154
  toKebabCase(str) {
2151
2155
  return str.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
@@ -3294,18 +3298,23 @@ class BuilderComponent {
3294
3298
  }
3295
3299
  }
3296
3300
  /**
3297
- * Set --preview-vh on .preview-scroll so that 100vh fills the visible canvas
3298
- * frame at the current scale. Value = canvas frame height ÷ scale ÷ 100, so
3299
- * calc(100 * var(--preview-vh)) equals the frame height in canvas-space pixels.
3300
- * Falls back to 1vh in the live page (no --preview-vh defined there).
3301
+ * Set --preview-vh / --preview-vw on .preview-scroll so that viewport-relative
3302
+ * units (vh, vw) inside the canvas resolve to the simulated canvas dimensions
3303
+ * rather than the real browser viewport.
3304
+ *
3305
+ * --preview-vh = canvas frame height (unscaled) / 100
3306
+ * --preview-vw = canvas width from viewport state / 100
3307
+ *
3308
+ * Both fall back to their native unit in production (no variables defined).
3301
3309
  */
3302
3310
  updatePreviewVh() {
3303
3311
  const el = this.previewScrollRef?.nativeElement;
3304
3312
  if (!el)
3305
3313
  return;
3306
- const scale = this.viewportService.getState().scale;
3307
- const frameH = el.clientHeight / scale;
3314
+ const state = this.viewportService.getState();
3315
+ const frameH = el.clientHeight / state.scale;
3308
3316
  el.style.setProperty('--preview-vh', `${frameH / 100}px`);
3317
+ el.style.setProperty('--preview-vw', `${state.width / 100}px`);
3309
3318
  this.canvasFrameHeight = Math.round(frameH);
3310
3319
  }
3311
3320
  initLenis() {