@bebranded/bb-contents 1.0.93-test → 1.0.95
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 +64 -38
- 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.94-test
|
|
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.94-test');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.94-test',
|
|
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)
|
|
@@ -289,9 +289,9 @@
|
|
|
289
289
|
mainContainer.style.cssText = `
|
|
290
290
|
position: relative;
|
|
291
291
|
width: 100%;
|
|
292
|
-
height: ${isVertical ? (height === 'auto' ? 'auto' : height + 'px') : '
|
|
293
|
-
overflow: hidden;
|
|
294
|
-
min-height:
|
|
292
|
+
height: ${isVertical ? (height === 'auto' ? 'auto' : height + 'px') : 'auto'};
|
|
293
|
+
overflow: ${isVertical ? 'hidden' : 'visible'};
|
|
294
|
+
min-height: auto;
|
|
295
295
|
${minHeight ? `min-height: ${minHeight};` : ''}
|
|
296
296
|
`;
|
|
297
297
|
|
|
@@ -385,46 +385,69 @@
|
|
|
385
385
|
const totalImages = images.length;
|
|
386
386
|
|
|
387
387
|
|
|
388
|
-
//
|
|
388
|
+
// SOLUTION MOBILE : Amélioration du rendu des images sur mobile
|
|
389
|
+
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) ||
|
|
390
|
+
(window.innerWidth <= 768 && /Chrome|CriOS/i.test(navigator.userAgent));
|
|
391
|
+
|
|
392
|
+
// OPTIMISATION: Charger les images en respectant le CSS Webflow
|
|
389
393
|
images.forEach(img => {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
+
// Préserver les styles CSS existants AVANT toute modification
|
|
395
|
+
const computedStyle = getComputedStyle(img);
|
|
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;
|
|
394
400
|
|
|
395
|
-
// OPTIMISATION:
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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
|
+
}
|
|
400
410
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (
|
|
407
|
-
img.
|
|
411
|
+
// Charger l'image si nécessaire
|
|
412
|
+
if (img.complete && img.naturalWidth > 0) {
|
|
413
|
+
// Image déjà chargée, ne rien toucher
|
|
414
|
+
imagesLoaded++;
|
|
415
|
+
} else {
|
|
416
|
+
if (img.dataset.src && !img.src) {
|
|
417
|
+
img.src = img.dataset.src;
|
|
408
418
|
}
|
|
409
419
|
|
|
410
|
-
// OPTIMISATION:
|
|
411
|
-
if (!
|
|
412
|
-
img.
|
|
413
|
-
}
|
|
414
|
-
if (!originalHeight || originalHeight === '') {
|
|
415
|
-
img.style.height = 'auto';
|
|
420
|
+
// OPTIMISATION MOBILE : Utiliser lazy loading natif au lieu de eager sur mobile
|
|
421
|
+
if (!img.loading) {
|
|
422
|
+
img.loading = isMobile ? 'lazy' : 'eager';
|
|
416
423
|
}
|
|
417
424
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
425
|
+
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
|
+
imagesLoaded++;
|
|
444
|
+
};
|
|
445
|
+
img.onerror = () => {
|
|
446
|
+
imagesLoaded++;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
423
449
|
});
|
|
424
450
|
|
|
425
|
-
// SOLUTION SAFARI MOBILE SIMPLE : Attendre plus longtemps
|
|
426
|
-
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
427
|
-
|
|
428
451
|
// Timeout plus long sur mobile pour laisser le temps aux images de se charger
|
|
429
452
|
const maxWaitTime = isMobile ? 5000 : 3000; // 5 secondes sur mobile
|
|
430
453
|
let waitTimeout = 0;
|
|
@@ -451,7 +474,10 @@
|
|
|
451
474
|
images.forEach(img => {
|
|
452
475
|
if (img.dataset.src && !img.src) {
|
|
453
476
|
img.src = img.dataset.src;
|
|
454
|
-
|
|
477
|
+
// Ne pas forcer eager sur mobile, laisser le lazy loading
|
|
478
|
+
if (!img.loading && !isMobile) {
|
|
479
|
+
img.loading = 'eager';
|
|
480
|
+
}
|
|
455
481
|
}
|
|
456
482
|
});
|
|
457
483
|
}
|