@bebranded/bb-contents 1.0.67-beta → 1.0.69-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 +51 -29
  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.67-beta
4
+ * @version 1.0.69-beta
5
5
  * @author BeBranded
6
6
  * @license MIT
7
7
  * @website https://www.bebranded.xyz
@@ -34,7 +34,7 @@
34
34
 
35
35
  // Configuration
36
36
  const config = {
37
- version: '1.0.67-beta',
37
+ version: '1.0.69-beta',
38
38
  debug: true, // Debug activé pour diagnostic
39
39
  prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
40
40
  youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
@@ -382,9 +382,12 @@
382
382
  initSafariAnimation: function(element, scrollContainer, mainBlock, options) {
383
383
  const { speed, direction, gap, isVertical, useAutoHeight, contentSize, gapSize } = options;
384
384
 
385
- // Créer les keyframes CSS pour Safari
385
+ console.log(`🔍 [MARQUEE] Safari Animation - direction: ${direction}, isVertical: ${isVertical}, contentSize: ${contentSize}`);
386
+
387
+ // Solution Safari hybride : JavaScript avec optimisations Safari
386
388
  const totalSize = contentSize * 3 + gapSize * 2;
387
- const animationName = `marquee-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
389
+ const step = (parseFloat(speed) * (isVertical ? 1.5 : 0.8)) / 60;
390
+ let isPaused = false;
388
391
 
389
392
  // Ajuster la taille du conteneur
390
393
  if (isVertical && !useAutoHeight) {
@@ -393,37 +396,56 @@
393
396
  scrollContainer.style.width = totalSize + 'px';
394
397
  }
395
398
 
396
- // Créer les keyframes CSS
397
- const keyframes = `
398
- @keyframes ${animationName} {
399
- 0% {
400
- transform: ${isVertical ? 'translateY(0px)' : 'translateX(0px)'};
401
- }
402
- 100% {
403
- transform: ${isVertical ? `translateY(-${contentSize + gapSize}px)` : `translateX(-${contentSize + gapSize}px)`};
404
- }
405
- }
406
- `;
399
+ // Position initiale optimisée pour Safari
400
+ let currentPosition;
401
+ if (direction === (isVertical ? 'bottom' : 'right')) {
402
+ currentPosition = -(contentSize + gapSize);
403
+ } else {
404
+ currentPosition = 0;
405
+ }
407
406
 
408
- // Injecter les keyframes dans le head
409
- const style = document.createElement('style');
410
- style.textContent = keyframes;
411
- document.head.appendChild(style);
407
+ // Forcer la position initiale pour éviter l'invisibilité
408
+ const initialTransform = isVertical
409
+ ? `translate3d(0, ${currentPosition}px, 0)`
410
+ : `translate3d(${currentPosition}px, 0, 0)`;
411
+ scrollContainer.style.transform = initialTransform;
412
+
413
+ console.log(`🔍 [MARQUEE] Safari - Position initiale: ${currentPosition}px, transform: ${initialTransform}`);
412
414
 
413
- // Configuration de l'animation
414
- const duration = (contentSize + gapSize) / ((parseFloat(speed) * (isVertical ? 1.5 : 0.8)) / 60);
415
- scrollContainer.style.animation = `${animationName} ${duration}s linear infinite`;
415
+ // Fonction d'animation Safari optimisée
416
+ const animate = () => {
417
+ if (!isPaused) {
418
+ if (direction === (isVertical ? 'bottom' : 'right')) {
419
+ currentPosition += step;
420
+ if (currentPosition >= 0) {
421
+ currentPosition = -(contentSize + gapSize);
422
+ }
423
+ } else {
424
+ currentPosition -= step;
425
+ if (currentPosition <= -(2 * (contentSize + gapSize))) {
426
+ currentPosition = -(contentSize + gapSize);
427
+ }
428
+ }
429
+
430
+ // Transform optimisé pour Safari avec will-change
431
+ const transform = isVertical
432
+ ? `translate3d(0, ${currentPosition}px, 0)`
433
+ : `translate3d(${currentPosition}px, 0, 0)`;
434
+ scrollContainer.style.transform = transform;
435
+ }
436
+ requestAnimationFrame(animate);
437
+ };
416
438
 
417
- console.log(' [MARQUEE] Animation Safari démarrée avec keyframes CSS');
439
+ // Démarrer l'animation avec un petit délai pour Safari
440
+ setTimeout(() => {
441
+ animate();
442
+ console.log('✅ [MARQUEE] Animation Safari démarrée avec JavaScript optimisé');
443
+ }, 50);
418
444
 
419
445
  // Pause au survol pour Safari
420
446
  if (element.getAttribute('bb-marquee-pause') === 'true') {
421
- element.addEventListener('mouseenter', () => {
422
- scrollContainer.style.animationPlayState = 'paused';
423
- });
424
- element.addEventListener('mouseleave', () => {
425
- scrollContainer.style.animationPlayState = 'running';
426
- });
447
+ element.addEventListener('mouseenter', () => isPaused = true);
448
+ element.addEventListener('mouseleave', () => isPaused = false);
427
449
  }
428
450
  },
429
451
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.67-beta",
3
+ "version": "1.0.69-beta",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {