eat-js-sdk 2.0.51 → 2.0.53
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/dist/interaction-builder.mjs +10 -14
- package/package.json +1 -1
|
@@ -7793,22 +7793,23 @@ function getDynamicMarginTop(containerElement) {
|
|
|
7793
7793
|
return "margin-top: 0px";
|
|
7794
7794
|
}
|
|
7795
7795
|
const windowHeight = window.innerHeight;
|
|
7796
|
-
|
|
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
|
-
|
|
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 (
|
|
7811
|
-
const marginTop = (availableSpace -
|
|
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 =
|
|
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
|
|
7825
|
+
return height;
|
|
7829
7826
|
},
|
|
7830
7827
|
cleanup: () => {
|
|
7831
|
-
window.removeEventListener("resize", updateHeight);
|
|
7832
7828
|
}
|
|
7833
7829
|
};
|
|
7834
7830
|
}
|