@bebranded/bb-contents 1.0.79-beta → 1.0.81-beta
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 +28 -34
- 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.80-beta
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -34,15 +34,13 @@
|
|
|
34
34
|
}
|
|
35
35
|
window._bbContentsInitialized = true;
|
|
36
36
|
|
|
37
|
-
// Log de démarrage
|
|
38
|
-
console.log('
|
|
39
|
-
console.log('🔍 [BB Contents] User Agent:', navigator.userAgent);
|
|
40
|
-
console.log('🔍 [BB Contents] Safari détecté:', /^((?!chrome|android).)*safari/i.test(navigator.userAgent));
|
|
37
|
+
// Log de démarrage simple
|
|
38
|
+
console.log('bb-contents | v1.0.81-beta');
|
|
41
39
|
|
|
42
40
|
// Configuration
|
|
43
41
|
const config = {
|
|
44
|
-
version: '1.0.
|
|
45
|
-
debug:
|
|
42
|
+
version: '1.0.81-beta',
|
|
43
|
+
debug: false, // Debug désactivé pour rendu propre
|
|
46
44
|
prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
|
|
47
45
|
youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
|
|
48
46
|
i18n: {
|
|
@@ -247,7 +245,7 @@
|
|
|
247
245
|
subtree: true
|
|
248
246
|
});
|
|
249
247
|
|
|
250
|
-
|
|
248
|
+
this.utils.log('MutationObserver actif');
|
|
251
249
|
}
|
|
252
250
|
};
|
|
253
251
|
|
|
@@ -255,14 +253,14 @@
|
|
|
255
253
|
bbContents.modules = {
|
|
256
254
|
// Module Marquee - Version simplifiée et robuste
|
|
257
255
|
marquee: {
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
detect: function(scope) {
|
|
257
|
+
const s = scope || document;
|
|
260
258
|
return s.querySelector(bbContents._attrSelector('marquee')) !== null;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
init: function(root) {
|
|
262
|
+
const scope = root || document;
|
|
263
|
+
if (scope.closest && scope.closest('[data-bb-disable]')) return;
|
|
266
264
|
const elements = scope.querySelectorAll(bbContents._attrSelector('marquee'));
|
|
267
265
|
|
|
268
266
|
console.log('🔍 [MARQUEE] Éléments trouvés:', elements.length);
|
|
@@ -273,9 +271,8 @@
|
|
|
273
271
|
if (element.bbProcessed || element.hasAttribute('data-bb-marquee-processed')) {
|
|
274
272
|
return;
|
|
275
273
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
console.log(`🔍 [MARQUEE] Initialisation ${index + 1}/${elements.length}`);
|
|
274
|
+
element.bbProcessed = true;
|
|
275
|
+
|
|
279
276
|
|
|
280
277
|
// Récupérer les options
|
|
281
278
|
const speed = bbContents._getAttr(element, 'bb-marquee-speed') || '100';
|
|
@@ -357,7 +354,6 @@
|
|
|
357
354
|
// Calculer les dimensions
|
|
358
355
|
const contentSize = isVertical ? mainBlock.offsetHeight : mainBlock.offsetWidth;
|
|
359
356
|
|
|
360
|
-
console.log(`🔍 [MARQUEE] Animation démarrée - contentSize: ${contentSize}px, isVertical: ${isVertical}`);
|
|
361
357
|
|
|
362
358
|
if (contentSize === 0) {
|
|
363
359
|
console.log('⚠️ [MARQUEE] Contenu vide, retry dans 200ms');
|
|
@@ -367,7 +363,6 @@
|
|
|
367
363
|
|
|
368
364
|
// Détection Safari
|
|
369
365
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
370
|
-
console.log(`🔍 [MARQUEE] Safari détecté: ${isSafari}`);
|
|
371
366
|
|
|
372
367
|
const gapSize = parseInt(gap);
|
|
373
368
|
const step = (parseFloat(speed) * (isVertical ? 1.5 : 0.8)) / 60;
|
|
@@ -389,14 +384,12 @@
|
|
|
389
384
|
initSafariAnimation: function(element, scrollContainer, mainBlock, options) {
|
|
390
385
|
const { speed, direction, gap, isVertical, useAutoHeight, contentSize, gapSize } = options;
|
|
391
386
|
|
|
392
|
-
console.log(`🔍 [MARQUEE] Safari Animation - direction: ${direction}, isVertical: ${isVertical}, contentSize: ${contentSize}`);
|
|
393
387
|
|
|
394
388
|
// SOLUTION SAFARI : Forcer le chargement des images avant animation
|
|
395
389
|
const images = mainBlock.querySelectorAll('img');
|
|
396
390
|
let imagesLoaded = 0;
|
|
397
391
|
const totalImages = images.length;
|
|
398
392
|
|
|
399
|
-
console.log(`🔍 [MARQUEE] Safari - ${totalImages} images détectées`);
|
|
400
393
|
|
|
401
394
|
// Forcer le chargement de toutes les images
|
|
402
395
|
images.forEach(img => {
|
|
@@ -406,20 +399,18 @@
|
|
|
406
399
|
}
|
|
407
400
|
img.onload = () => {
|
|
408
401
|
imagesLoaded++;
|
|
409
|
-
console.log(`🖼️ [MARQUEE] Safari - Image ${imagesLoaded}/${totalImages} chargée`);
|
|
410
402
|
};
|
|
411
403
|
img.onerror = () => {
|
|
412
404
|
imagesLoaded++;
|
|
413
|
-
console.log(`❌ [MARQUEE] Safari - Image ${imagesLoaded}/${totalImages} erreur de chargement`);
|
|
414
405
|
};
|
|
415
406
|
});
|
|
416
407
|
|
|
417
|
-
//
|
|
418
|
-
let waitTimeout = 0;
|
|
419
|
-
const maxWaitTime = 3000; // 3 secondes max sur mobile
|
|
408
|
+
// SOLUTION SAFARI MOBILE SIMPLE : Attendre plus longtemps
|
|
420
409
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
421
410
|
|
|
422
|
-
|
|
411
|
+
// Timeout plus long sur mobile pour laisser le temps aux images de se charger
|
|
412
|
+
const maxWaitTime = isMobile ? 5000 : 3000; // 5 secondes sur mobile
|
|
413
|
+
let waitTimeout = 0;
|
|
423
414
|
|
|
424
415
|
const waitForImages = () => {
|
|
425
416
|
waitTimeout += 100;
|
|
@@ -427,16 +418,19 @@
|
|
|
427
418
|
if (imagesLoaded >= totalImages || imagesLoaded === 0 || waitTimeout >= maxWaitTime) {
|
|
428
419
|
console.log(`✅ [MARQUEE] Safari - Images chargées: ${imagesLoaded}/${totalImages} (timeout: ${waitTimeout}ms)`);
|
|
429
420
|
|
|
430
|
-
// Attendre
|
|
421
|
+
// Attendre plus longtemps sur mobile pour le rendu visuel
|
|
422
|
+
const renderDelay = isMobile ? 1000 : 200;
|
|
431
423
|
setTimeout(() => {
|
|
432
424
|
console.log(`🖼️ [MARQUEE] Safari - Attente rendu visuel des images...`);
|
|
433
425
|
startSafariAnimation();
|
|
434
|
-
},
|
|
426
|
+
}, renderDelay);
|
|
435
427
|
} else {
|
|
436
428
|
setTimeout(waitForImages, 100);
|
|
437
429
|
}
|
|
438
430
|
};
|
|
439
431
|
|
|
432
|
+
waitForImages();
|
|
433
|
+
|
|
440
434
|
const startSafariAnimation = () => {
|
|
441
435
|
// Forcer le chargement des images restantes si timeout
|
|
442
436
|
if (waitTimeout >= maxWaitTime && imagesLoaded < totalImages) {
|
|
@@ -493,7 +487,7 @@
|
|
|
493
487
|
let currentPosition;
|
|
494
488
|
if (direction === (isVertical ? 'bottom' : 'right')) {
|
|
495
489
|
currentPosition = -(finalContentSize + gapSize);
|
|
496
|
-
|
|
490
|
+
} else {
|
|
497
491
|
currentPosition = 0;
|
|
498
492
|
}
|
|
499
493
|
|
|
@@ -517,7 +511,7 @@
|
|
|
517
511
|
console.log(`🔄 [MARQUEE] Safari RESET bottom/right: ${currentPosition} → ${-(finalContentSize + gapSize)}`);
|
|
518
512
|
currentPosition = -(finalContentSize + gapSize);
|
|
519
513
|
}
|
|
520
|
-
|
|
514
|
+
} else {
|
|
521
515
|
currentPosition -= step;
|
|
522
516
|
if (currentPosition <= -(2 * (finalContentSize + gapSize))) {
|
|
523
517
|
console.log(`🔄 [MARQUEE] Safari RESET top/left: ${currentPosition} → ${-(finalContentSize + gapSize)}`);
|
|
@@ -928,8 +922,8 @@
|
|
|
928
922
|
// Debug: logger la qualité utilisée (en mode debug seulement)
|
|
929
923
|
if (bbContents.config.debug) {
|
|
930
924
|
// Thumbnail optimisée
|
|
931
|
-
|
|
932
|
-
|
|
925
|
+
}
|
|
926
|
+
} else {
|
|
933
927
|
// Aucune thumbnail disponible
|
|
934
928
|
}
|
|
935
929
|
}
|