eat-js-sdk 2.0.51 → 2.0.52

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.
@@ -7793,22 +7793,23 @@ function getDynamicMarginTop(containerElement) {
7793
7793
  return "margin-top: 0px";
7794
7794
  }
7795
7795
  const windowHeight = window.innerHeight;
7796
- let contentHeight = containerElement.scrollHeight;
7796
+ const contentHeight = containerElement.scrollHeight;
7797
+ if (contentHeight <= 0 || windowHeight <= 0) {
7798
+ return "margin-top: 0px";
7799
+ }
7797
7800
  const rect = containerElement.getBoundingClientRect();
7798
7801
  const images = containerElement.querySelectorAll("img");
7799
7802
  const hasUnloadedImages = Array.from(images).some((img) => !img.complete);
7803
+ let adjustedHeight = contentHeight;
7800
7804
  if (hasUnloadedImages && images.length > 0) {
7801
7805
  const firstImg = images[0];
7802
7806
  const estimatedImgHeight = firstImg.naturalHeight || LAYOUT_CONFIG.DEFAULT_IMAGE_HEIGHT;
7803
- contentHeight = Math.max(contentHeight, estimatedImgHeight + LAYOUT_CONFIG.IMAGE_PADDING);
7804
- }
7805
- if (contentHeight <= 0) {
7806
- return "margin-top: 0px";
7807
+ adjustedHeight = Math.max(contentHeight, estimatedImgHeight + LAYOUT_CONFIG.IMAGE_PADDING);
7807
7808
  }
7808
7809
  const containerTop = rect.top;
7809
7810
  const availableSpace = windowHeight - containerTop;
7810
- if (contentHeight < availableSpace) {
7811
- const marginTop = (availableSpace - contentHeight) / 2;
7811
+ if (adjustedHeight < availableSpace) {
7812
+ const marginTop = (availableSpace - adjustedHeight) / 2;
7812
7813
  return `margin-top: ${Math.max(0, marginTop)}px`;
7813
7814
  }
7814
7815
  return "margin-top: 0px";
@@ -7818,17 +7819,12 @@ function getWindowHeight() {
7818
7819
  return { value: 0, cleanup: () => {
7819
7820
  } };
7820
7821
  }
7821
- let height = /* @__PURE__ */ state(proxy(window.innerHeight));
7822
- const updateHeight = () => {
7823
- set(height, window.innerHeight, true);
7824
- };
7825
- window.addEventListener("resize", updateHeight);
7822
+ let height = proxy(window.innerHeight);
7826
7823
  return {
7827
7824
  get value() {
7828
- return get$1(height);
7825
+ return height;
7829
7826
  },
7830
7827
  cleanup: () => {
7831
- window.removeEventListener("resize", updateHeight);
7832
7828
  }
7833
7829
  };
7834
7830
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eat-js-sdk",
3
- "version": "2.0.51",
3
+ "version": "2.0.52",
4
4
  "change version": "2.0.0",
5
5
  "description": "Authoring tool frontend SDK",
6
6
  "contributors": [