@michaelyagi/shoji 0.1.0-beta.6 → 0.1.0-beta.7

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.
@@ -1902,6 +1902,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1902
1902
  __publicField(this, "captureGestureStartState", () => {
1903
1903
  this.controlsHiddenAtGestureStart = this.autoHidden;
1904
1904
  });
1905
+ /**
1906
+ * A real mobile bug (DESIGN.md §2.6a): after scrolling far enough to
1907
+ * collapse a mobile browser's own URL bar, `window.innerHeight` grows
1908
+ * but `.shoji-outer`'s painted size didn't follow, off-centering the
1909
+ * photo. `visualViewport.height` reflects the true visible area;
1910
+ * `window`'s `resize` is the fallback where it's unsupported.
1911
+ */
1912
+ __publicField(this, "syncViewportHeight", () => {
1913
+ var _a;
1914
+ if (!this.dom) return;
1915
+ const height = ((_a = window.visualViewport) == null ? void 0 : _a.height) ?? window.innerHeight;
1916
+ this.dom.outer.style.height = `${height}px`;
1917
+ });
1905
1918
  __publicField(this, "onKeydown", (event) => {
1906
1919
  if (document.activeElement instanceof HTMLVideoElement && event.key !== "Escape") return;
1907
1920
  this.onActivity();
@@ -2939,6 +2952,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2939
2952
  naturalSize && !((_a = this.itemList[index]) == null ? void 0 : _a.video) ? this.resolveOpenPlaceholderSrc(this.itemList[index], origin) : void 0
2940
2953
  );
2941
2954
  this.dom.outer.classList.add("shoji-open");
2955
+ this.syncViewportHeight();
2956
+ if (window.visualViewport)
2957
+ window.visualViewport.addEventListener("resize", this.syncViewportHeight);
2958
+ else window.addEventListener("resize", this.syncViewportHeight);
2942
2959
  document.addEventListener("keydown", this.onKeydown);
2943
2960
  this.focusTrap.activate(this.dom.dialog);
2944
2961
  this.scheduleAutoHide();
@@ -3163,8 +3180,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3163
3180
  this.opened = false;
3164
3181
  unlockBodyScroll();
3165
3182
  document.removeEventListener("keydown", this.onKeydown);
3183
+ if (window.visualViewport)
3184
+ window.visualViewport.removeEventListener("resize", this.syncViewportHeight);
3185
+ else window.removeEventListener("resize", this.syncViewportHeight);
3166
3186
  this.focusTrap.deactivate();
3167
3187
  (_a = this.dom) == null ? void 0 : _a.outer.classList.remove("shoji-open");
3188
+ if (this.dom) this.dom.outer.style.height = "";
3168
3189
  if (this.dom) this.dom.backdrop.style.opacity = "";
3169
3190
  if (this.autoHideTimer !== null) {
3170
3191
  clearTimeout(this.autoHideTimer);