@bebranded/bb-contents 1.0.97 → 1.0.99
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 +43 -24
- 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.99
|
|
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.99');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.99',
|
|
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)
|
|
@@ -320,13 +320,9 @@
|
|
|
320
320
|
${isVertical ? 'min-height: 100px;' : ''}
|
|
321
321
|
`;
|
|
322
322
|
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
const repeatBlock2 = mainBlock.cloneNode(true);
|
|
326
|
-
|
|
323
|
+
// Ne créer que le mainBlock pour l'instant
|
|
324
|
+
// Les copies seront créées après le chargement des images
|
|
327
325
|
scrollContainer.appendChild(mainBlock);
|
|
328
|
-
scrollContainer.appendChild(repeatBlock1);
|
|
329
|
-
scrollContainer.appendChild(repeatBlock2);
|
|
330
326
|
mainContainer.appendChild(scrollContainer);
|
|
331
327
|
|
|
332
328
|
element.innerHTML = '';
|
|
@@ -368,6 +364,12 @@
|
|
|
368
364
|
speed, direction, gap, isVertical, useAutoHeight, contentSize, gapSize
|
|
369
365
|
});
|
|
370
366
|
} else {
|
|
367
|
+
// Solution standard : créer les copies maintenant (les navigateurs non-Safari gèrent mieux)
|
|
368
|
+
const repeatBlock1 = mainBlock.cloneNode(true);
|
|
369
|
+
const repeatBlock2 = mainBlock.cloneNode(true);
|
|
370
|
+
scrollContainer.appendChild(repeatBlock1);
|
|
371
|
+
scrollContainer.appendChild(repeatBlock2);
|
|
372
|
+
|
|
371
373
|
// Solution standard pour autres navigateurs
|
|
372
374
|
this.initStandardAnimation(element, scrollContainer, mainBlock, {
|
|
373
375
|
speed, direction, pauseOnHover, gap, isVertical, useAutoHeight, contentSize, gapSize, step
|
|
@@ -389,14 +391,16 @@
|
|
|
389
391
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) ||
|
|
390
392
|
(window.innerWidth <= 768 && /Chrome|CriOS/i.test(navigator.userAgent));
|
|
391
393
|
|
|
392
|
-
// SOLUTION MOBILE :
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
394
|
+
// SOLUTION MOBILE : Charger toutes les images AVANT de créer les copies pour éviter le flou
|
|
395
|
+
const loadImage = (img) => {
|
|
396
|
+
return new Promise((resolve) => {
|
|
397
|
+
if (img.complete && img.naturalWidth > 0 && img.naturalHeight > 0) {
|
|
398
|
+
// Image déjà chargée et rendue
|
|
399
|
+
imagesLoaded++;
|
|
400
|
+
resolve();
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
|
|
400
404
|
if (img.dataset.src && !img.src) {
|
|
401
405
|
img.src = img.dataset.src;
|
|
402
406
|
}
|
|
@@ -408,12 +412,19 @@
|
|
|
408
412
|
|
|
409
413
|
img.onload = () => {
|
|
410
414
|
imagesLoaded++;
|
|
415
|
+
// Forcer un reflow pour s'assurer que l'image est rendue
|
|
416
|
+
void img.offsetHeight;
|
|
417
|
+
resolve();
|
|
411
418
|
};
|
|
412
419
|
img.onerror = () => {
|
|
413
420
|
imagesLoaded++;
|
|
421
|
+
resolve(); // Résoudre même en cas d'erreur
|
|
414
422
|
};
|
|
415
|
-
}
|
|
416
|
-
}
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// Charger toutes les images en parallèle
|
|
427
|
+
Promise.all(Array.from(images).map(loadImage));
|
|
417
428
|
|
|
418
429
|
// Timeout plus long sur mobile pour laisser le temps aux images de se charger
|
|
419
430
|
const maxWaitTime = isMobile ? 5000 : 3000; // 5 secondes sur mobile
|
|
@@ -423,11 +434,19 @@
|
|
|
423
434
|
waitTimeout += 100;
|
|
424
435
|
|
|
425
436
|
if (imagesLoaded >= totalImages || imagesLoaded === 0 || waitTimeout >= maxWaitTime) {
|
|
426
|
-
// Attendre
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
437
|
+
// Attendre un frame pour le rendu complet, surtout sur mobile
|
|
438
|
+
requestAnimationFrame(() => {
|
|
439
|
+
requestAnimationFrame(() => {
|
|
440
|
+
// Maintenant créer les copies avec les images complètement chargées
|
|
441
|
+
const repeatBlock1 = mainBlock.cloneNode(true);
|
|
442
|
+
const repeatBlock2 = mainBlock.cloneNode(true);
|
|
443
|
+
scrollContainer.appendChild(repeatBlock1);
|
|
444
|
+
scrollContainer.appendChild(repeatBlock2);
|
|
445
|
+
|
|
446
|
+
// Démarrer l'animation
|
|
447
|
+
startSafariAnimation();
|
|
448
|
+
});
|
|
449
|
+
});
|
|
431
450
|
} else {
|
|
432
451
|
setTimeout(waitForImages, 100);
|
|
433
452
|
}
|