@aarhus-university/au-designsystem-delphinus 1.6.8 → 1.6.9
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/CHANGELOG.md +1 -1
- package/package.json +1 -1
- package/source/js/omnibus/app.ts +16 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/source/js/omnibus/app.ts
CHANGED
|
@@ -174,6 +174,7 @@ function updateImageSize(imageContainer, img) {
|
|
|
174
174
|
const containerHeight = containerWidth * (2 / 3);
|
|
175
175
|
img.style.width = containerWidth + 'px';
|
|
176
176
|
img.style.height = containerHeight + 'px';
|
|
177
|
+
img.style.objectFit = 'cover';
|
|
177
178
|
|
|
178
179
|
const src = img.src;
|
|
179
180
|
const src2x = src.replace('.jpg', '@2x.jpg').replace('.png', '@2x.png');
|
|
@@ -182,7 +183,7 @@ function updateImageSize(imageContainer, img) {
|
|
|
182
183
|
fetch(src2x, { method: 'HEAD' })
|
|
183
184
|
.then(response => {
|
|
184
185
|
if (response.ok) {
|
|
185
|
-
img.setAttribute('srcset', `${src} 1x, ${src2x}
|
|
186
|
+
img.setAttribute('srcset', `${src} 1x, ${src2x} 2x`);
|
|
186
187
|
} else {
|
|
187
188
|
img.setAttribute('srcset', `${src} 1x`);
|
|
188
189
|
}
|
|
@@ -210,3 +211,17 @@ window.addEventListener('resize', () => {
|
|
|
210
211
|
}
|
|
211
212
|
});
|
|
212
213
|
});
|
|
214
|
+
|
|
215
|
+
// Initial update to set sizes on load
|
|
216
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
217
|
+
const containers = document.querySelectorAll('.news-story__normal');
|
|
218
|
+
|
|
219
|
+
containers.forEach(container => {
|
|
220
|
+
const imageContainer = container.querySelector('.news-story__image-container');
|
|
221
|
+
const img = imageContainer?.querySelector('img.news-story__image');
|
|
222
|
+
|
|
223
|
+
if (img instanceof HTMLImageElement) {
|
|
224
|
+
updateImageSize(imageContainer, img);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|