@bebranded/bb-contents 1.0.66-beta → 1.0.67-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 +76 -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.67-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.67-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,82 @@
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
+ // Créer les keyframes CSS pour Safari
386
+ const totalSize = contentSize * 3 + gapSize * 2;
387
+ const animationName = `marquee-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
388
+
389
+ // Ajuster la taille du conteneur
390
+ if (isVertical && !useAutoHeight) {
391
+ scrollContainer.style.height = totalSize + 'px';
392
+ } else if (!isVertical) {
393
+ scrollContainer.style.width = totalSize + 'px';
394
+ }
395
+
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
+ `;
407
+
408
+ // Injecter les keyframes dans le head
409
+ const style = document.createElement('style');
410
+ style.textContent = keyframes;
411
+ document.head.appendChild(style);
412
+
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`;
416
+
417
+ console.log('✅ [MARQUEE] Animation Safari démarrée avec keyframes CSS');
418
+
419
+ // Pause au survol pour Safari
420
+ 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
+ });
427
+ }
428
+ },
429
+
430
+ initStandardAnimation: function(element, scrollContainer, mainBlock, options) {
431
+ const { speed, direction, pauseOnHover, gap, isVertical, useAutoHeight, contentSize, gapSize, step } = options;
432
+
433
+ const totalSize = contentSize * 3 + gapSize * 2;
434
+ let isPaused = false;
366
435
 
367
- // Position initiale optimisée pour Safari
436
+ // Position initiale
368
437
  let currentPosition;
369
438
  if (direction === (isVertical ? 'bottom' : 'right')) {
370
439
  currentPosition = -(contentSize + gapSize);
@@ -379,24 +448,21 @@
379
448
  scrollContainer.style.width = totalSize + 'px';
380
449
  }
381
450
 
382
- // Fonction d'animation Safari-compatible
451
+ // Fonction d'animation standard
383
452
  const animate = () => {
384
453
  if (!isPaused) {
385
454
  if (direction === (isVertical ? 'bottom' : 'right')) {
386
455
  currentPosition += step;
387
- // Reset Safari-compatible pour direction bottom/right
388
456
  if (currentPosition >= 0) {
389
457
  currentPosition = -(contentSize + gapSize);
390
458
  }
391
459
  } else {
392
460
  currentPosition -= step;
393
- // Reset Safari-compatible pour direction top/left
394
461
  if (currentPosition <= -(2 * (contentSize + gapSize))) {
395
462
  currentPosition = -(contentSize + gapSize);
396
463
  }
397
464
  }
398
465
 
399
- // Transform optimisé pour Safari
400
466
  const transform = isVertical
401
467
  ? `translate3d(0, ${currentPosition}px, 0)`
402
468
  : `translate3d(${currentPosition}px, 0, 0)`;
@@ -407,7 +473,7 @@
407
473
 
408
474
  // Démarrer l'animation
409
475
  animate();
410
- console.log('✅ [MARQUEE] Animation démarrée avec succès (Safari-compatible)');
476
+ console.log('✅ [MARQUEE] Animation standard démarrée');
411
477
 
412
478
  // Pause au survol
413
479
  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.67-beta",
4
4
  "description": "Contenus additionnels français pour Webflow",
5
5
  "main": "bb-contents.js",
6
6
  "scripts": {