oasys-lib 0.0.2-rc.2 → 0.0.2-rc.3
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/fesm2022/oasys-lib.mjs
CHANGED
|
@@ -1038,19 +1038,7 @@ class ImageComponent {
|
|
|
1038
1038
|
return;
|
|
1039
1039
|
}
|
|
1040
1040
|
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1041
|
-
const
|
|
1042
|
-
if (!entry) {
|
|
1043
|
-
return;
|
|
1044
|
-
}
|
|
1045
|
-
let width = 0;
|
|
1046
|
-
const borderBox = entry.borderBoxSize;
|
|
1047
|
-
if (borderBox) {
|
|
1048
|
-
const box = Array.isArray(borderBox) ? borderBox[0] : borderBox;
|
|
1049
|
-
width = box.inlineSize;
|
|
1050
|
-
}
|
|
1051
|
-
else {
|
|
1052
|
-
width = entry.target.getBoundingClientRect().width;
|
|
1053
|
-
}
|
|
1041
|
+
const width = entries[0].borderBoxSize[0].inlineSize;
|
|
1054
1042
|
const rounded = Math.round(width);
|
|
1055
1043
|
if (rounded <= 0 || rounded === this.measuredWidthPx()) {
|
|
1056
1044
|
return;
|
|
@@ -1147,13 +1135,16 @@ class ImageComponent {
|
|
|
1147
1135
|
return url && !Number.isNaN(width) ? { url, width } : null;
|
|
1148
1136
|
})
|
|
1149
1137
|
.filter((candidate) => candidate !== null);
|
|
1138
|
+
if (candidates.length === 0) {
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1150
1141
|
const atOrAbove = candidates
|
|
1151
1142
|
.filter(({ width }) => width >= targetWidth)
|
|
1152
|
-
.sort((a, b) => a.width - b.width)
|
|
1153
|
-
if (atOrAbove) {
|
|
1154
|
-
return atOrAbove.url;
|
|
1143
|
+
.sort((a, b) => a.width - b.width);
|
|
1144
|
+
if (atOrAbove.length > 0) {
|
|
1145
|
+
return atOrAbove[0].url;
|
|
1155
1146
|
}
|
|
1156
|
-
return candidates.sort((a, b) => b.width - a.width)[0]
|
|
1147
|
+
return candidates.sort((a, b) => b.width - a.width)[0].url;
|
|
1157
1148
|
}
|
|
1158
1149
|
/**
|
|
1159
1150
|
* Cleans up the IntersectionObserver to prevent memory leaks.
|