@bebranded/bb-contents 1.0.65-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 +89 -12
  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.65-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.65-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,12 +358,89 @@
358
358
  return;
359
359
  }
360
360
 
361
- // Configuration de l'animation
362
- const totalSize = contentSize * 3 + parseInt(gap) * 2;
363
- let currentPosition = direction === (isVertical ? 'bottom' : 'right') ? -contentSize - parseInt(gap) : 0;
361
+ // Détection Safari
362
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
363
+ console.log(`🔍 [MARQUEE] Safari détecté: ${isSafari}`);
364
+
365
+ const gapSize = parseInt(gap);
364
366
  const step = (parseFloat(speed) * (isVertical ? 1.5 : 0.8)) / 60;
365
367
  let isPaused = false;
366
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;
435
+
436
+ // Position initiale
437
+ let currentPosition;
438
+ if (direction === (isVertical ? 'bottom' : 'right')) {
439
+ currentPosition = -(contentSize + gapSize);
440
+ } else {
441
+ currentPosition = 0;
442
+ }
443
+
367
444
  // Ajuster la taille du conteneur
368
445
  if (isVertical && !useAutoHeight) {
369
446
  scrollContainer.style.height = totalSize + 'px';
@@ -371,24 +448,24 @@
371
448
  scrollContainer.style.width = totalSize + 'px';
372
449
  }
373
450
 
374
- // Fonction d'animation
451
+ // Fonction d'animation standard
375
452
  const animate = () => {
376
453
  if (!isPaused) {
377
454
  if (direction === (isVertical ? 'bottom' : 'right')) {
378
455
  currentPosition += step;
379
456
  if (currentPosition >= 0) {
380
- currentPosition = -contentSize - parseInt(gap);
457
+ currentPosition = -(contentSize + gapSize);
381
458
  }
382
459
  } else {
383
460
  currentPosition -= step;
384
- if (currentPosition <= -contentSize - parseInt(gap)) {
385
- currentPosition = 0;
461
+ if (currentPosition <= -(2 * (contentSize + gapSize))) {
462
+ currentPosition = -(contentSize + gapSize);
386
463
  }
387
464
  }
388
465
 
389
466
  const transform = isVertical
390
- ? `translate3d(0px, ${currentPosition}px, 0px)`
391
- : `translate3d(${currentPosition}px, 0px, 0px)`;
467
+ ? `translate3d(0, ${currentPosition}px, 0)`
468
+ : `translate3d(${currentPosition}px, 0, 0)`;
392
469
  scrollContainer.style.transform = transform;
393
470
  }
394
471
  requestAnimationFrame(animate);
@@ -396,7 +473,7 @@
396
473
 
397
474
  // Démarrer l'animation
398
475
  animate();
399
- console.log('✅ [MARQUEE] Animation démarrée avec succès');
476
+ console.log('✅ [MARQUEE] Animation standard démarrée');
400
477
 
401
478
  // Pause au survol
402
479
  if (pauseOnHover === 'true') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bebranded/bb-contents",
3
- "version": "1.0.65-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": {