@bebranded/bb-contents 1.0.16-beta → 1.0.18-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.
- package/bb-contents.js +53 -24
- 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.
|
|
4
|
+
* @version 1.0.18-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.
|
|
20
|
+
version: '1.0.18-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: {
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
}
|
|
305
305
|
},
|
|
306
306
|
|
|
307
|
-
// Module Marquee
|
|
307
|
+
// Module Marquee - Version hybride (CSS + JavaScript)
|
|
308
308
|
marquee: {
|
|
309
309
|
detect: function(scope) {
|
|
310
310
|
return scope.querySelector('[bb-marquee]') !== null;
|
|
@@ -320,7 +320,8 @@
|
|
|
320
320
|
if (element.bbProcessed) return;
|
|
321
321
|
element.bbProcessed = true;
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
// Récupérer les options avec valeurs par défaut optimisées
|
|
324
|
+
const speed = bbContents._getAttr(element, 'bb-marquee-speed') || '100';
|
|
324
325
|
const direction = bbContents._getAttr(element, 'bb-marquee-direction') || 'left';
|
|
325
326
|
const pause = bbContents._getAttr(element, 'bb-marquee-pause') || 'true';
|
|
326
327
|
const gap = bbContents._getAttr(element, 'bb-marquee-gap') || '50';
|
|
@@ -328,6 +329,9 @@
|
|
|
328
329
|
const height = bbContents._getAttr(element, 'bb-marquee-height');
|
|
329
330
|
const minHeight = bbContents._getAttr(element, 'bb-marquee-min-height');
|
|
330
331
|
|
|
332
|
+
// Calculer la vitesse en millisecondes (comme la version live)
|
|
333
|
+
const speedMs = parseInt(speed);
|
|
334
|
+
|
|
331
335
|
// Créer le conteneur principal
|
|
332
336
|
const mainContainer = document.createElement('div');
|
|
333
337
|
mainContainer.style.cssText = `
|
|
@@ -338,26 +342,25 @@
|
|
|
338
342
|
${minHeight ? `min-height: ${minHeight};` : ''}
|
|
339
343
|
`;
|
|
340
344
|
|
|
341
|
-
// Créer le conteneur de défilement
|
|
345
|
+
// Créer le conteneur de défilement avec animation CSS de base
|
|
342
346
|
const scrollContainer = document.createElement('div');
|
|
343
347
|
scrollContainer.style.cssText = `
|
|
344
348
|
display: flex;
|
|
345
349
|
align-items: center;
|
|
346
350
|
${orientation === 'vertical' ? 'flex-direction: column;' : ''}
|
|
347
351
|
gap: ${gap}px;
|
|
348
|
-
|
|
349
|
-
${
|
|
350
|
-
${orientation === 'vertical' ? 'animation-name: marquee-vertical;' : ''}
|
|
352
|
+
will-change: transform;
|
|
353
|
+
${orientation === 'vertical' ? 'white-space: nowrap;' : ''}
|
|
351
354
|
`;
|
|
352
355
|
|
|
353
|
-
//
|
|
356
|
+
// Dupliquer le contenu pour l'effet infini
|
|
354
357
|
const originalContent = element.innerHTML;
|
|
355
|
-
scrollContainer.innerHTML = originalContent + originalContent;
|
|
358
|
+
scrollContainer.innerHTML = originalContent + originalContent;
|
|
356
359
|
|
|
357
|
-
// Ajouter les styles CSS
|
|
360
|
+
// Ajouter les styles CSS optimisés
|
|
358
361
|
const style = document.createElement('style');
|
|
359
362
|
style.textContent = `
|
|
360
|
-
@keyframes marquee {
|
|
363
|
+
@keyframes marquee-horizontal {
|
|
361
364
|
0% { transform: translateX(0); }
|
|
362
365
|
100% { transform: translateX(-50%); }
|
|
363
366
|
}
|
|
@@ -368,13 +371,48 @@
|
|
|
368
371
|
`;
|
|
369
372
|
document.head.appendChild(style);
|
|
370
373
|
|
|
374
|
+
// Fonction d'animation JavaScript pour contrôle précis (comme la version live)
|
|
375
|
+
const isVertical = orientation === 'vertical';
|
|
376
|
+
let animationId;
|
|
377
|
+
let startTime;
|
|
378
|
+
let currentPosition = 0;
|
|
379
|
+
const contentSize = isVertical ? scrollContainer.scrollHeight / 2 : scrollContainer.scrollWidth / 2;
|
|
380
|
+
|
|
381
|
+
const animate = (timestamp) => {
|
|
382
|
+
if (!startTime) startTime = timestamp;
|
|
383
|
+
const elapsed = timestamp - startTime;
|
|
384
|
+
|
|
385
|
+
// Calculer la position basée sur la vitesse (comme la version live)
|
|
386
|
+
const progress = (elapsed % speedMs) / speedMs;
|
|
387
|
+
currentPosition = -progress * contentSize;
|
|
388
|
+
|
|
389
|
+
// Appliquer la transformation
|
|
390
|
+
if (isVertical) {
|
|
391
|
+
scrollContainer.style.transform = `translateY(${currentPosition}px)`;
|
|
392
|
+
} else {
|
|
393
|
+
scrollContainer.style.transform = `translateX(${currentPosition}px)`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
animationId = requestAnimationFrame(animate);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// Démarrer l'animation
|
|
400
|
+
setTimeout(() => {
|
|
401
|
+
animationId = requestAnimationFrame(animate);
|
|
402
|
+
}, 100);
|
|
403
|
+
|
|
371
404
|
// Pause au survol
|
|
372
405
|
if (pause === 'true') {
|
|
373
406
|
mainContainer.addEventListener('mouseenter', () => {
|
|
374
|
-
|
|
407
|
+
if (animationId) {
|
|
408
|
+
cancelAnimationFrame(animationId);
|
|
409
|
+
animationId = null;
|
|
410
|
+
}
|
|
375
411
|
});
|
|
376
412
|
mainContainer.addEventListener('mouseleave', () => {
|
|
377
|
-
|
|
413
|
+
if (!animationId) {
|
|
414
|
+
animationId = requestAnimationFrame(animate);
|
|
415
|
+
}
|
|
378
416
|
});
|
|
379
417
|
}
|
|
380
418
|
|
|
@@ -395,18 +433,9 @@
|
|
|
395
433
|
mainContainer.appendChild(scrollContainer);
|
|
396
434
|
element.innerHTML = '';
|
|
397
435
|
element.appendChild(mainContainer);
|
|
398
|
-
|
|
399
|
-
// Délai pour l'animation
|
|
400
|
-
const isVertical = orientation === 'vertical';
|
|
401
|
-
setTimeout(() => {
|
|
402
|
-
scrollContainer.style.animation = `marquee${isVertical ? '-vertical' : ''} ${speed}s linear infinite`;
|
|
403
|
-
if (direction === 'right') {
|
|
404
|
-
scrollContainer.style.animationDirection = 'reverse';
|
|
405
|
-
}
|
|
406
|
-
}, isVertical ? 300 : 100);
|
|
407
436
|
});
|
|
408
437
|
|
|
409
|
-
bbContents.utils.log('Module Marquee initialisé:', elements.length, 'éléments');
|
|
438
|
+
bbContents.utils.log('Module Marquee hybride initialisé:', elements.length, 'éléments');
|
|
410
439
|
}
|
|
411
440
|
},
|
|
412
441
|
|