@bebranded/bb-contents 1.0.35-beta → 1.0.36-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.
Files changed (2) hide show
  1. package/bb-contents.js +22 -9
  2. package/package.json +1 -1
package/bb-contents.js CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  // Configuration
19
19
  const config = {
20
- version: '1.0.35-beta',
20
+ version: '1.0.36-beta',
21
21
  debug: true, // Activé temporairement pour debug
22
22
  prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
23
23
  i18n: {
@@ -470,14 +470,27 @@
470
470
  const initAnimation = (retryCount = 0) => {
471
471
  // Attendre que le contenu soit dans le DOM
472
472
  requestAnimationFrame(() => {
473
- const contentWidth = mainBlock.offsetWidth;
474
- const contentHeight = mainBlock.offsetHeight;
473
+ // Calcul plus robuste des dimensions
474
+ const rect = mainBlock.getBoundingClientRect();
475
+ const contentWidth = rect.width || mainBlock.offsetWidth;
476
+ const contentHeight = rect.height || mainBlock.offsetHeight;
477
+
478
+ // Pour les marquees verticaux, utiliser la largeur du parent si nécessaire
479
+ let finalWidth = contentWidth;
480
+ let finalHeight = contentHeight;
481
+
482
+ if (isVertical && contentWidth < 10) {
483
+ // Si largeur trop petite, utiliser la largeur du parent
484
+ const parentRect = mainBlock.parentElement.getBoundingClientRect();
485
+ finalWidth = parentRect.width || mainBlock.parentElement.offsetWidth;
486
+ bbContents.utils.log('Largeur corrigée pour marquee vertical:', finalWidth, 'px (était:', contentWidth, 'px)');
487
+ }
475
488
 
476
489
  // Debug amélioré
477
- bbContents.utils.log('Debug - Largeur du contenu:', contentWidth, 'px', 'Hauteur:', contentHeight, 'px', 'Enfants:', mainBlock.children.length, 'Vertical:', isVertical, 'Direction:', direction, 'Tentative:', retryCount + 1);
490
+ bbContents.utils.log('Debug - Largeur du contenu:', finalWidth, 'px', 'Hauteur:', finalHeight, 'px', 'Enfants:', mainBlock.children.length, 'Vertical:', isVertical, 'Direction:', direction, 'Tentative:', retryCount + 1);
478
491
 
479
492
  // Si pas de contenu, réessayer avec délai progressif
480
- if ((isVertical && contentHeight === 0) || (!isVertical && contentWidth === 0)) {
493
+ if ((isVertical && finalHeight === 0) || (!isVertical && finalWidth === 0)) {
481
494
  if (retryCount < 5) {
482
495
  bbContents.utils.log('Contenu non prêt, nouvelle tentative dans', (200 + retryCount * 100), 'ms');
483
496
  setTimeout(() => initAnimation(retryCount + 1), 200 + retryCount * 100);
@@ -489,9 +502,9 @@
489
502
  }
490
503
 
491
504
  // Pour le vertical, s'assurer qu'on a une hauteur minimale
492
- if (isVertical && contentHeight < 50) {
505
+ if (isVertical && finalHeight < 50) {
493
506
  if (retryCount < 5) {
494
- bbContents.utils.log('Hauteur insuffisante pour le marquee vertical (' + contentHeight + 'px), nouvelle tentative dans', (200 + retryCount * 100), 'ms');
507
+ bbContents.utils.log('Hauteur insuffisante pour le marquee vertical (' + finalHeight + 'px), nouvelle tentative dans', (200 + retryCount * 100), 'ms');
495
508
  setTimeout(() => initAnimation(retryCount + 1), 200 + retryCount * 100);
496
509
  return;
497
510
  } else {
@@ -502,7 +515,7 @@
502
515
 
503
516
  if (isVertical) {
504
517
  // Animation JavaScript pour le vertical
505
- const contentSize = contentHeight;
518
+ const contentSize = finalHeight;
506
519
  const totalSize = contentSize * 4 + parseInt(gap) * 3; // 4 copies au lieu de 3
507
520
 
508
521
  // Ajuster la hauteur du scrollContainer seulement si pas en mode auto
@@ -550,7 +563,7 @@
550
563
  }
551
564
  } else {
552
565
  // Animation JavaScript pour l'horizontal (comme le vertical pour éviter les saccades)
553
- const contentSize = contentWidth;
566
+ const contentSize = finalWidth;
554
567
  const totalSize = contentSize * 4 + parseInt(gap) * 3;
555
568
  scrollContainer.style.width = totalSize + 'px';
556
569
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.35-beta",
3
+ "version": "1.0.36-beta",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {