@bebranded/bb-contents 1.1.19 → 1.1.20
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 +29 -8
- 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.1.
|
|
4
|
+
* @version 1.1.20
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
// Version du script
|
|
13
|
-
const BB_CONTENTS_VERSION = '1.1.
|
|
13
|
+
const BB_CONTENTS_VERSION = '1.1.20';
|
|
14
14
|
|
|
15
15
|
// Créer l'objet temporaire pour la configuration si il n'existe pas
|
|
16
16
|
if (!window._bbContentsConfig) {
|
|
@@ -297,7 +297,7 @@
|
|
|
297
297
|
block.querySelector('[class*="dropdown"]') !== null;
|
|
298
298
|
},
|
|
299
299
|
|
|
300
|
-
// Dropdown en portal
|
|
300
|
+
// Dropdown en portal : position fixe *par rapport au toggle* (mise à jour au scroll/resize pour suivre le bouton)
|
|
301
301
|
_enableMarqueeDropdowns: function(block) {
|
|
302
302
|
if (!block || !block.querySelectorAll) return;
|
|
303
303
|
const items = block.querySelectorAll('.bb-marquee_item, [role="listitem"]');
|
|
@@ -312,12 +312,24 @@
|
|
|
312
312
|
dropdown.style.overflow = 'visible';
|
|
313
313
|
let portalWrapper = null;
|
|
314
314
|
let leaveTimer = null;
|
|
315
|
+
let scrollResizeCleanup = null;
|
|
315
316
|
|
|
316
317
|
var marqueeEl = dropdown.closest('[data-bb-marquee-processed]');
|
|
317
318
|
|
|
319
|
+
function updatePortalPosition() {
|
|
320
|
+
if (!portalWrapper || !portalWrapper.parentNode) return;
|
|
321
|
+
var rect = toggle.getBoundingClientRect();
|
|
322
|
+
portalWrapper.style.right = (window.innerWidth - rect.right) + 'px';
|
|
323
|
+
portalWrapper.style.top = rect.top + 'px';
|
|
324
|
+
}
|
|
325
|
+
|
|
318
326
|
function closePortal() {
|
|
319
327
|
if (leaveTimer) clearTimeout(leaveTimer);
|
|
320
328
|
leaveTimer = null;
|
|
329
|
+
if (scrollResizeCleanup) {
|
|
330
|
+
scrollResizeCleanup();
|
|
331
|
+
scrollResizeCleanup = null;
|
|
332
|
+
}
|
|
321
333
|
if (portalWrapper && portalWrapper.parentNode) {
|
|
322
334
|
portalWrapper.parentNode.removeChild(portalWrapper);
|
|
323
335
|
}
|
|
@@ -331,15 +343,15 @@
|
|
|
331
343
|
leaveTimer = null;
|
|
332
344
|
if (portalWrapper && portalWrapper.parentNode) return;
|
|
333
345
|
if (marqueeEl) marqueeEl.setAttribute('data-bb-marquee-dropdown-open', '1');
|
|
334
|
-
|
|
335
|
-
|
|
346
|
+
var rect = toggle.getBoundingClientRect();
|
|
347
|
+
var listStyle = getComputedStyle(list);
|
|
336
348
|
portalWrapper = document.createElement('div');
|
|
337
349
|
portalWrapper.setAttribute('data-bb-marquee-dropdown-portal', 'true');
|
|
338
350
|
portalWrapper.className = 'w-dropdown';
|
|
339
351
|
portalWrapper.style.cssText =
|
|
340
|
-
'position:fixed;
|
|
341
|
-
|
|
342
|
-
|
|
352
|
+
'position:fixed;transform:translateY(-100%);margin-top:-4px;z-index:9999;background:none;border:none;';
|
|
353
|
+
updatePortalPosition();
|
|
354
|
+
var clone = list.cloneNode(true);
|
|
343
355
|
clone.style.display = 'block';
|
|
344
356
|
clone.style.background = listStyle.background || listStyle.backgroundColor || 'transparent';
|
|
345
357
|
clone.style.backgroundColor = listStyle.backgroundColor;
|
|
@@ -354,6 +366,15 @@
|
|
|
354
366
|
});
|
|
355
367
|
document.body.appendChild(portalWrapper);
|
|
356
368
|
dropdown.classList.add('w--open');
|
|
369
|
+
var onScrollOrResize = function() {
|
|
370
|
+
updatePortalPosition();
|
|
371
|
+
};
|
|
372
|
+
window.addEventListener('scroll', onScrollOrResize, true);
|
|
373
|
+
window.addEventListener('resize', onScrollOrResize);
|
|
374
|
+
scrollResizeCleanup = function() {
|
|
375
|
+
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
376
|
+
window.removeEventListener('resize', onScrollOrResize);
|
|
377
|
+
};
|
|
357
378
|
}
|
|
358
379
|
|
|
359
380
|
dropdown.addEventListener('mouseenter', function() {
|