@bebranded/bb-contents 1.0.24-beta → 1.0.26-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 +33 -33
  2. 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.24-beta
4
+ * @version 1.0.26-beta
5
5
  * @author BeBranded
6
6
  * @license MIT
7
7
  * @website https://www.bebranded.xyz
@@ -17,7 +17,7 @@
17
17
 
18
18
  // Configuration
19
19
  const config = {
20
- version: '1.0.24-beta',
20
+ version: '1.0.26-beta',
21
21
  debug: window.location.hostname === 'localhost' || window.location.hostname.includes('webflow.io'),
22
22
  prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
23
23
  i18n: {
@@ -465,47 +465,47 @@
465
465
  });
466
466
  }
467
467
  } else {
468
- // Animation CSS pour l'horizontal (modifiée)
468
+ // Animation JavaScript pour l'horizontal (comme le vertical pour éviter les saccades)
469
469
  const contentSize = contentWidth;
470
- const totalSize = contentSize * 4 + parseInt(gap) * 3; // 4 copies au lieu de 3
470
+ const totalSize = contentSize * 4 + parseInt(gap) * 3;
471
471
  scrollContainer.style.width = totalSize + 'px';
472
472
 
473
- // Créer l'animation CSS optimisée
474
- const animationName = 'bb-scroll-' + Math.random().toString(36).substr(2, 9);
475
- const animationDuration = (totalSize / (parseFloat(speed) * 1.5)).toFixed(2) + 's'; // Vitesse différente
473
+ let currentPosition = direction === 'right' ? -contentSize - parseInt(gap) : 0;
474
+ const step = (parseFloat(speed) * 0.5) / 60; // Vitesse réduite pour l'horizontal
475
+ let isPaused = false;
476
476
 
477
- // Animation avec translate3d pour hardware acceleration
478
- let keyframes;
479
- if (direction === 'right') {
480
- keyframes = `@keyframes ${animationName} {
481
- 0% { transform: translate3d(-${contentSize + parseInt(gap)}px, 0px, 0px); }
482
- 100% { transform: translate3d(0px, 0px, 0px); }
483
- }`;
484
- } else {
485
- // Direction 'left' par défaut
486
- keyframes = `@keyframes ${animationName} {
487
- 0% { transform: translate3d(0px, 0px, 0px); }
488
- 100% { transform: translate3d(-${contentSize + parseInt(gap)}px, 0px, 0px); }
489
- }`;
490
- }
491
-
492
- // Ajouter les styles
493
- const style = document.createElement('style');
494
- style.textContent = keyframes;
495
- document.head.appendChild(style);
496
-
497
- // Appliquer l'animation
498
- scrollContainer.style.animation = `${animationName} ${animationDuration} linear infinite`;
477
+ // Fonction d'animation JavaScript
478
+ const animate = () => {
479
+ if (!isPaused) {
480
+ if (direction === 'right') {
481
+ currentPosition += step;
482
+ if (currentPosition >= 0) {
483
+ currentPosition = -contentSize - parseInt(gap);
484
+ }
485
+ } else {
486
+ currentPosition -= step;
487
+ if (currentPosition <= -contentSize - parseInt(gap)) {
488
+ currentPosition = 0;
489
+ }
490
+ }
491
+
492
+ scrollContainer.style.transform = `translate3d(${currentPosition}px, 0px, 0px)`;
493
+ }
494
+ requestAnimationFrame(animate);
495
+ };
496
+
497
+ // Démarrer l'animation
498
+ animate();
499
+
500
+ bbContents.utils.log('Marquee horizontal créé avec animation JS - direction:', direction, 'taille:', contentSize + 'px', 'total:', totalSize + 'px');
499
501
 
500
- bbContents.utils.log('Marquee horizontal créé:', animationName, 'durée:', animationDuration + 's', 'direction:', direction, 'taille:', contentSize + 'px', 'total:', totalSize + 'px');
501
-
502
502
  // Pause au survol
503
503
  if (pauseOnHover === 'true') {
504
504
  element.addEventListener('mouseenter', function() {
505
- scrollContainer.style.animationPlayState = 'paused';
505
+ isPaused = true;
506
506
  });
507
507
  element.addEventListener('mouseleave', function() {
508
- scrollContainer.style.animationPlayState = 'running';
508
+ isPaused = false;
509
509
  });
510
510
  }
511
511
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.24-beta",
3
+ "version": "1.0.26-beta",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {