@bebranded/bb-contents 1.0.66-beta → 1.0.68-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 +96 -10
  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.66-beta
4
+ * @version 1.0.68-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.66-beta',
37
+ version: '1.0.68-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)
@@ -358,13 +358,102 @@
358
358
  return;
359
359
  }
360
360
 
361
- // Configuration de l'animation - Logique Safari-compatible
361
+ // Détection Safari
362
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
363
+ console.log(`🔍 [MARQUEE] Safari détecté: ${isSafari}`);
364
+
362
365
  const gapSize = parseInt(gap);
363
- const totalSize = contentSize * 3 + gapSize * 2;
364
366
  const step = (parseFloat(speed) * (isVertical ? 1.5 : 0.8)) / 60;
365
367
  let isPaused = false;
368
+
369
+ if (isSafari) {
370
+ // Solution Safari : Animation CSS avec keyframes
371
+ this.initSafariAnimation(element, scrollContainer, mainBlock, {
372
+ speed, direction, gap, isVertical, useAutoHeight, contentSize, gapSize
373
+ });
374
+ } else {
375
+ // Solution standard pour autres navigateurs
376
+ this.initStandardAnimation(element, scrollContainer, mainBlock, {
377
+ speed, direction, pauseOnHover, gap, isVertical, useAutoHeight, contentSize, gapSize, step
378
+ });
379
+ }
380
+ },
381
+
382
+ initSafariAnimation: function(element, scrollContainer, mainBlock, options) {
383
+ const { speed, direction, gap, isVertical, useAutoHeight, contentSize, gapSize } = options;
384
+
385
+ console.log(`🔍 [MARQUEE] Safari Animation - direction: ${direction}, isVertical: ${isVertical}`);
386
+
387
+ // Créer les keyframes CSS pour Safari avec direction
388
+ const totalSize = contentSize * 3 + gapSize * 2;
389
+ const animationName = `marquee-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
390
+
391
+ // Ajuster la taille du conteneur
392
+ if (isVertical && !useAutoHeight) {
393
+ scrollContainer.style.height = totalSize + 'px';
394
+ } else if (!isVertical) {
395
+ scrollContainer.style.width = totalSize + 'px';
396
+ }
397
+
398
+ // Calculer les positions selon la direction
399
+ let startPos, endPos;
400
+ const moveDistance = contentSize + gapSize;
401
+
402
+ if (direction === (isVertical ? 'bottom' : 'right')) {
403
+ // Direction bottom/right : commence en bas/à droite, va vers le haut/à gauche
404
+ startPos = isVertical ? `translateY(${moveDistance}px)` : `translateX(${moveDistance}px)`;
405
+ endPos = isVertical ? 'translateY(0px)' : 'translateX(0px)';
406
+ } else {
407
+ // Direction top/left : commence en haut/à gauche, va vers le bas/à droite
408
+ startPos = isVertical ? 'translateY(0px)' : 'translateX(0px)';
409
+ endPos = isVertical ? `translateY(-${moveDistance}px)` : `translateX(-${moveDistance}px)`;
410
+ }
411
+
412
+ // Créer les keyframes CSS avec direction
413
+ const keyframes = `
414
+ @keyframes ${animationName} {
415
+ 0% {
416
+ transform: ${startPos};
417
+ }
418
+ 100% {
419
+ transform: ${endPos};
420
+ }
421
+ }
422
+ `;
423
+
424
+ // Injecter les keyframes dans le head
425
+ const style = document.createElement('style');
426
+ style.textContent = keyframes;
427
+ document.head.appendChild(style);
428
+
429
+ // Configuration de l'animation avec durée calculée correctement
430
+ const speedValue = parseFloat(speed);
431
+ const baseSpeed = isVertical ? 1.5 : 0.8;
432
+ const duration = Math.max(1, moveDistance / ((speedValue * baseSpeed) / 60));
433
+
434
+ scrollContainer.style.animation = `${animationName} ${duration}s linear infinite`;
435
+
436
+ console.log(`🔍 [MARQUEE] Safari - duration: ${duration}s, moveDistance: ${moveDistance}px`);
437
+ console.log('✅ [MARQUEE] Animation Safari démarrée avec keyframes CSS');
438
+
439
+ // Pause au survol pour Safari
440
+ if (element.getAttribute('bb-marquee-pause') === 'true') {
441
+ element.addEventListener('mouseenter', () => {
442
+ scrollContainer.style.animationPlayState = 'paused';
443
+ });
444
+ element.addEventListener('mouseleave', () => {
445
+ scrollContainer.style.animationPlayState = 'running';
446
+ });
447
+ }
448
+ },
449
+
450
+ initStandardAnimation: function(element, scrollContainer, mainBlock, options) {
451
+ const { speed, direction, pauseOnHover, gap, isVertical, useAutoHeight, contentSize, gapSize, step } = options;
452
+
453
+ const totalSize = contentSize * 3 + gapSize * 2;
454
+ let isPaused = false;
366
455
 
367
- // Position initiale optimisée pour Safari
456
+ // Position initiale
368
457
  let currentPosition;
369
458
  if (direction === (isVertical ? 'bottom' : 'right')) {
370
459
  currentPosition = -(contentSize + gapSize);
@@ -379,24 +468,21 @@
379
468
  scrollContainer.style.width = totalSize + 'px';
380
469
  }
381
470
 
382
- // Fonction d'animation Safari-compatible
471
+ // Fonction d'animation standard
383
472
  const animate = () => {
384
473
  if (!isPaused) {
385
474
  if (direction === (isVertical ? 'bottom' : 'right')) {
386
475
  currentPosition += step;
387
- // Reset Safari-compatible pour direction bottom/right
388
476
  if (currentPosition >= 0) {
389
477
  currentPosition = -(contentSize + gapSize);
390
478
  }
391
479
  } else {
392
480
  currentPosition -= step;
393
- // Reset Safari-compatible pour direction top/left
394
481
  if (currentPosition <= -(2 * (contentSize + gapSize))) {
395
482
  currentPosition = -(contentSize + gapSize);
396
483
  }
397
484
  }
398
485
 
399
- // Transform optimisé pour Safari
400
486
  const transform = isVertical
401
487
  ? `translate3d(0, ${currentPosition}px, 0)`
402
488
  : `translate3d(${currentPosition}px, 0, 0)`;
@@ -407,7 +493,7 @@
407
493
 
408
494
  // Démarrer l'animation
409
495
  animate();
410
- console.log('✅ [MARQUEE] Animation démarrée avec succès (Safari-compatible)');
496
+ console.log('✅ [MARQUEE] Animation standard démarrée');
411
497
 
412
498
  // Pause au survol
413
499
  if (pauseOnHover === 'true') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.66-beta",
3
+ "version": "1.0.68-beta",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {