@bebranded/bb-contents 1.0.17-beta → 1.0.19-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 -39
- 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.19-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.19-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 simplifiée et corrigée
|
|
308
308
|
marquee: {
|
|
309
309
|
detect: function(scope) {
|
|
310
310
|
return scope.querySelector('[bb-marquee]') !== null;
|
|
@@ -320,6 +320,7 @@
|
|
|
320
320
|
if (element.bbProcessed) return;
|
|
321
321
|
element.bbProcessed = true;
|
|
322
322
|
|
|
323
|
+
// Récupérer les options
|
|
323
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';
|
|
@@ -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
|
+
// Sauvegarder le contenu original
|
|
333
|
+
const originalContent = element.innerHTML;
|
|
334
|
+
|
|
331
335
|
// Créer le conteneur principal
|
|
332
336
|
const mainContainer = document.createElement('div');
|
|
333
337
|
mainContainer.style.cssText = `
|
|
@@ -345,36 +349,60 @@
|
|
|
345
349
|
align-items: center;
|
|
346
350
|
${orientation === 'vertical' ? 'flex-direction: column;' : ''}
|
|
347
351
|
gap: ${gap}px;
|
|
348
|
-
|
|
349
|
-
${direction === 'right' ? 'animation-direction: reverse;' : ''}
|
|
350
|
-
${orientation === 'vertical' ? 'animation-name: marquee-vertical;' : ''}
|
|
352
|
+
will-change: transform;
|
|
351
353
|
`;
|
|
352
354
|
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
355
|
+
// Dupliquer le contenu
|
|
356
|
+
scrollContainer.innerHTML = originalContent + originalContent;
|
|
357
|
+
|
|
358
|
+
// Assembler
|
|
359
|
+
mainContainer.appendChild(scrollContainer);
|
|
360
|
+
element.innerHTML = '';
|
|
361
|
+
element.appendChild(mainContainer);
|
|
362
|
+
|
|
363
|
+
// Animation JavaScript simple et efficace
|
|
364
|
+
const isVertical = orientation === 'vertical';
|
|
365
|
+
let animationId;
|
|
366
|
+
let startTime;
|
|
367
|
+
let currentPosition = 0;
|
|
368
|
+
|
|
369
|
+
const animate = (timestamp) => {
|
|
370
|
+
if (!startTime) startTime = timestamp;
|
|
371
|
+
const elapsed = timestamp - startTime;
|
|
372
|
+
|
|
373
|
+
// Vitesse en millisecondes
|
|
374
|
+
const speedMs = parseInt(speed);
|
|
375
|
+
const progress = (elapsed % speedMs) / speedMs;
|
|
376
|
+
|
|
377
|
+
// Calculer la taille du contenu
|
|
378
|
+
const contentSize = isVertical ? scrollContainer.scrollHeight / 2 : scrollContainer.scrollWidth / 2;
|
|
379
|
+
currentPosition = -progress * contentSize;
|
|
380
|
+
|
|
381
|
+
// Appliquer la transformation
|
|
382
|
+
scrollContainer.style.transform = isVertical
|
|
383
|
+
? `translateY(${currentPosition}px)`
|
|
384
|
+
: `translateX(${currentPosition}px)`;
|
|
385
|
+
|
|
386
|
+
animationId = requestAnimationFrame(animate);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// Démarrer l'animation
|
|
390
|
+
setTimeout(() => {
|
|
391
|
+
animationId = requestAnimationFrame(animate);
|
|
392
|
+
}, 100);
|
|
370
393
|
|
|
371
394
|
// Pause au survol
|
|
372
395
|
if (pause === 'true') {
|
|
373
396
|
mainContainer.addEventListener('mouseenter', () => {
|
|
374
|
-
|
|
397
|
+
if (animationId) {
|
|
398
|
+
cancelAnimationFrame(animationId);
|
|
399
|
+
animationId = null;
|
|
400
|
+
}
|
|
375
401
|
});
|
|
376
402
|
mainContainer.addEventListener('mouseleave', () => {
|
|
377
|
-
|
|
403
|
+
if (!animationId) {
|
|
404
|
+
animationId = requestAnimationFrame(animate);
|
|
405
|
+
}
|
|
378
406
|
});
|
|
379
407
|
}
|
|
380
408
|
|
|
@@ -390,20 +418,6 @@
|
|
|
390
418
|
mainContainer.style.height = maxHeight + 'px';
|
|
391
419
|
}
|
|
392
420
|
}
|
|
393
|
-
|
|
394
|
-
// Assembler
|
|
395
|
-
mainContainer.appendChild(scrollContainer);
|
|
396
|
-
element.innerHTML = '';
|
|
397
|
-
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}ms linear infinite`;
|
|
403
|
-
if (direction === 'right') {
|
|
404
|
-
scrollContainer.style.animationDirection = 'reverse';
|
|
405
|
-
}
|
|
406
|
-
}, isVertical ? 300 : 100);
|
|
407
421
|
});
|
|
408
422
|
|
|
409
423
|
bbContents.utils.log('Module Marquee initialisé:', elements.length, 'éléments');
|