@bebranded/bb-contents 1.1.14 → 1.1.15
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 +39 -9
- 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.15
|
|
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.15';
|
|
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
|
-
// Active le comportement hover pour les dropdowns dans un bloc du marquee (
|
|
300
|
+
// Active le comportement hover pour les dropdowns dans un bloc du marquee (portal hors scrollContainer pour éviter le clipping)
|
|
301
301
|
_enableMarqueeDropdowns: function(block) {
|
|
302
302
|
if (!block || !block.querySelectorAll) return;
|
|
303
303
|
const items = block.querySelectorAll('.bb-marquee_item, [role="listitem"]');
|
|
@@ -306,19 +306,49 @@
|
|
|
306
306
|
const dropdowns = item.querySelectorAll('.w-dropdown, [class*="dropdown"]');
|
|
307
307
|
dropdowns.forEach(function(dropdown) {
|
|
308
308
|
const list = dropdown.querySelector('.w-dropdown-list, [class*="dropdown-list"], [class*="dropdown_list"]');
|
|
309
|
-
|
|
309
|
+
const toggle = dropdown.querySelector('.w-dropdown-toggle, [class*="dropdown-toggle"]');
|
|
310
|
+
if (!list || !toggle) return;
|
|
310
311
|
item.style.overflow = 'visible';
|
|
311
312
|
dropdown.style.overflow = 'visible';
|
|
312
|
-
list.style.zIndex = '10';
|
|
313
313
|
let leaveTimer;
|
|
314
|
-
|
|
314
|
+
let portalWrapper = null;
|
|
315
|
+
|
|
316
|
+
function closePortal() {
|
|
317
|
+
if (portalWrapper && portalWrapper.parentNode) {
|
|
318
|
+
portalWrapper.parentNode.removeChild(portalWrapper);
|
|
319
|
+
}
|
|
320
|
+
portalWrapper = null;
|
|
321
|
+
dropdown.classList.remove('w--open');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function openPortal() {
|
|
315
325
|
clearTimeout(leaveTimer);
|
|
326
|
+
if (portalWrapper && portalWrapper.parentNode) return;
|
|
327
|
+
const rect = toggle.getBoundingClientRect();
|
|
328
|
+
portalWrapper = document.createElement('div');
|
|
329
|
+
portalWrapper.setAttribute('data-bb-marquee-dropdown-portal', 'true');
|
|
330
|
+
portalWrapper.style.cssText = 'position:fixed;left:' + rect.left + 'px;top:' + (rect.bottom + 4) + 'px;z-index:9999;';
|
|
331
|
+
const clone = list.cloneNode(true);
|
|
332
|
+
clone.style.display = 'block';
|
|
333
|
+
clone.style.visibility = 'visible';
|
|
334
|
+
clone.style.opacity = '1';
|
|
335
|
+
clone.style.position = 'absolute';
|
|
336
|
+
clone.style.left = '0';
|
|
337
|
+
clone.style.top = '0';
|
|
338
|
+
portalWrapper.appendChild(clone);
|
|
339
|
+
portalWrapper.addEventListener('mouseenter', function() { clearTimeout(leaveTimer); });
|
|
340
|
+
portalWrapper.addEventListener('mouseleave', function() {
|
|
341
|
+
leaveTimer = setTimeout(closePortal, 150);
|
|
342
|
+
});
|
|
343
|
+
document.body.appendChild(portalWrapper);
|
|
316
344
|
dropdown.classList.add('w--open');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
dropdown.addEventListener('mouseenter', function() {
|
|
348
|
+
openPortal();
|
|
317
349
|
});
|
|
318
350
|
dropdown.addEventListener('mouseleave', function() {
|
|
319
|
-
leaveTimer = setTimeout(
|
|
320
|
-
dropdown.classList.remove('w--open');
|
|
321
|
-
}, 150);
|
|
351
|
+
leaveTimer = setTimeout(closePortal, 150);
|
|
322
352
|
});
|
|
323
353
|
});
|
|
324
354
|
});
|