@bebranded/bb-contents 1.0.95 → 1.0.97
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/bb-contents.js +7 -40
- package/package.json +1 -1
package/bb-contents.js
CHANGED
|
@@ -389,57 +389,24 @@
|
|
|
389
389
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) ||
|
|
390
390
|
(window.innerWidth <= 768 && /Chrome|CriOS/i.test(navigator.userAgent));
|
|
391
391
|
|
|
392
|
-
//
|
|
392
|
+
// SOLUTION MOBILE : Laisser les images tranquilles, le CSS Webflow gère mieux
|
|
393
393
|
images.forEach(img => {
|
|
394
|
-
//
|
|
395
|
-
|
|
396
|
-
const originalObjectFit = img.style.objectFit || computedStyle.objectFit;
|
|
397
|
-
const originalObjectPosition = img.style.objectPosition || computedStyle.objectPosition;
|
|
398
|
-
const originalWidth = computedStyle.width;
|
|
399
|
-
const originalHeight = computedStyle.height;
|
|
400
|
-
|
|
401
|
-
// OPTIMISATION MOBILE : Améliorer le rendu des images sur mobile
|
|
402
|
-
if (isMobile) {
|
|
403
|
-
// Forcer le rendu haute qualité sur mobile
|
|
404
|
-
img.style.imageRendering = 'auto';
|
|
405
|
-
img.style.backfaceVisibility = 'hidden';
|
|
406
|
-
img.style.webkitBackfaceVisibility = 'hidden';
|
|
407
|
-
img.style.transform = 'translateZ(0)';
|
|
408
|
-
img.style.webkitTransform = 'translateZ(0)';
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Charger l'image si nécessaire
|
|
394
|
+
// Charger l'image si nécessaire, mais ne pas toucher aux styles CSS
|
|
395
|
+
// Le CSS de Webflow est optimisé et on ne veut pas interférer
|
|
412
396
|
if (img.complete && img.naturalWidth > 0) {
|
|
413
|
-
// Image déjà chargée
|
|
397
|
+
// Image déjà chargée
|
|
414
398
|
imagesLoaded++;
|
|
415
399
|
} else {
|
|
416
400
|
if (img.dataset.src && !img.src) {
|
|
417
401
|
img.src = img.dataset.src;
|
|
418
402
|
}
|
|
419
403
|
|
|
420
|
-
//
|
|
421
|
-
if (!img.loading) {
|
|
422
|
-
img.loading =
|
|
404
|
+
// Utiliser eager sur mobile pour éviter le flou de lazy loading
|
|
405
|
+
if (!img.loading && isMobile) {
|
|
406
|
+
img.loading = 'eager';
|
|
423
407
|
}
|
|
424
408
|
|
|
425
409
|
img.onload = () => {
|
|
426
|
-
// OPTIMISATION: Restaurer les styles CSS après chargement
|
|
427
|
-
if (originalObjectFit && originalObjectFit !== 'none') {
|
|
428
|
-
img.style.objectFit = originalObjectFit;
|
|
429
|
-
}
|
|
430
|
-
if (originalObjectPosition && originalObjectPosition !== 'initial') {
|
|
431
|
-
img.style.objectPosition = originalObjectPosition;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// OPTIMISATION MOBILE : Respecter les dimensions CSS de Webflow
|
|
435
|
-
// Ne PAS forcer auto si les dimensions CSS sont définies dans Webflow
|
|
436
|
-
// Le CSS de Webflow prend toujours le dessus
|
|
437
|
-
|
|
438
|
-
// Forcer le recalcul pour mobile (important pour le rendu)
|
|
439
|
-
if (isMobile) {
|
|
440
|
-
img.offsetHeight; // Force reflow pour meilleur rendu
|
|
441
|
-
}
|
|
442
|
-
|
|
443
410
|
imagesLoaded++;
|
|
444
411
|
};
|
|
445
412
|
img.onerror = () => {
|