@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 CHANGED
@@ -1,4 +1,4 @@
1
- ## 1.6.0 - 1-6.7 (May 23, 2024)
1
+ ## 1.6.0 - 1.6.9 (May 23, 2024)
2
2
  ### Delphinus Projects Updates
3
3
  * Omnibus hotfixes for launch
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarhus-university/au-designsystem-delphinus",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "start": "concurrently \"npm run nodemon\" \"npm run sass\" \"npm run build\"",
@@ -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} 1x`);
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
+ });