@bebranded/bb-contents 1.0.106 → 1.0.108
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 +51 -4
- package/package.json +1 -1
package/bb-contents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BeBranded Contents
|
|
3
3
|
* Contenus additionnels français pour Webflow
|
|
4
|
-
* @version 1.0.
|
|
4
|
+
* @version 1.0.108
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
window._bbContentsInitialized = true;
|
|
33
33
|
|
|
34
34
|
// Log de démarrage simple (une seule fois)
|
|
35
|
-
console.log('bb-contents | v1.0.
|
|
35
|
+
console.log('bb-contents | v1.0.108');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.108',
|
|
40
40
|
debug: false, // Debug désactivé pour rendu propre
|
|
41
41
|
prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
|
|
42
42
|
youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
|
|
@@ -438,13 +438,22 @@
|
|
|
438
438
|
const waitForImages = () => {
|
|
439
439
|
waitTimeout += 100;
|
|
440
440
|
|
|
441
|
-
|
|
441
|
+
// Attendre que TOUTES les images soient chargées (ou s'il n'y a pas d'images, attendre un minimum)
|
|
442
|
+
if (totalImages === 0) {
|
|
443
|
+
// Pas d'images, démarrer après un court délai
|
|
444
|
+
const renderDelay = isMobile ? 500 : 100;
|
|
445
|
+
setTimeout(() => {
|
|
446
|
+
startSafariAnimation();
|
|
447
|
+
}, renderDelay);
|
|
448
|
+
} else if (imagesLoaded >= totalImages || waitTimeout >= maxWaitTime) {
|
|
449
|
+
// Toutes les images sont chargées OU timeout atteint
|
|
442
450
|
// Attendre plus longtemps sur mobile pour le rendu visuel
|
|
443
451
|
const renderDelay = isMobile ? 1000 : 200;
|
|
444
452
|
setTimeout(() => {
|
|
445
453
|
startSafariAnimation();
|
|
446
454
|
}, renderDelay);
|
|
447
455
|
} else {
|
|
456
|
+
// Continuer à attendre
|
|
448
457
|
setTimeout(waitForImages, 100);
|
|
449
458
|
}
|
|
450
459
|
};
|
|
@@ -452,6 +461,44 @@
|
|
|
452
461
|
waitForImages();
|
|
453
462
|
|
|
454
463
|
const startSafariAnimation = () => {
|
|
464
|
+
// Forcer le chargement des images restantes si timeout
|
|
465
|
+
if (waitTimeout >= maxWaitTime && imagesLoaded < totalImages) {
|
|
466
|
+
images.forEach(img => {
|
|
467
|
+
if (img.dataset.src && !img.src) {
|
|
468
|
+
img.src = img.dataset.src;
|
|
469
|
+
img.loading = 'eager';
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// CORRECTION: Appliquer les styles CSS aux images dans les copies également
|
|
475
|
+
// pour éviter les images floues ou mal cadrées
|
|
476
|
+
const allImages = scrollContainer.querySelectorAll('img');
|
|
477
|
+
allImages.forEach(img => {
|
|
478
|
+
// Vérifier si l'image a déjà des styles inline
|
|
479
|
+
if (!img.style.objectFit) {
|
|
480
|
+
const computedStyle = getComputedStyle(img);
|
|
481
|
+
const objectFit = computedStyle.objectFit;
|
|
482
|
+
const objectPosition = computedStyle.objectPosition;
|
|
483
|
+
|
|
484
|
+
// Appliquer object-fit si défini dans le CSS
|
|
485
|
+
if (objectFit && objectFit !== 'none' && objectFit !== 'fill') {
|
|
486
|
+
img.style.objectFit = objectFit;
|
|
487
|
+
}
|
|
488
|
+
// Appliquer object-position si défini dans le CSS
|
|
489
|
+
if (objectPosition && objectPosition !== 'initial' && objectPosition !== '50% 50%') {
|
|
490
|
+
img.style.objectPosition = objectPosition;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
// Vérifier que les images ont une taille visible
|
|
496
|
+
let imagesWithSize = 0;
|
|
497
|
+
images.forEach(img => {
|
|
498
|
+
if (img.offsetWidth > 0 && img.offsetHeight > 0) {
|
|
499
|
+
imagesWithSize++;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
455
502
|
|
|
456
503
|
// Recalculer la taille après chargement des images
|
|
457
504
|
const newContentSize = isVertical ? mainBlock.offsetHeight : mainBlock.offsetWidth;
|