@bebranded/bb-contents 1.1.14 → 1.1.16
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 +35 -12
- 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.16
|
|
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.16';
|
|
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,8 @@
|
|
|
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
|
+
// Respecte le design Webflow : position au-dessus du logo, pas de surcharge de styles, pas de latence.
|
|
301
302
|
_enableMarqueeDropdowns: function(block) {
|
|
302
303
|
if (!block || !block.querySelectorAll) return;
|
|
303
304
|
const items = block.querySelectorAll('.bb-marquee_item, [role="listitem"]');
|
|
@@ -306,19 +307,41 @@
|
|
|
306
307
|
const dropdowns = item.querySelectorAll('.w-dropdown, [class*="dropdown"]');
|
|
307
308
|
dropdowns.forEach(function(dropdown) {
|
|
308
309
|
const list = dropdown.querySelector('.w-dropdown-list, [class*="dropdown-list"], [class*="dropdown_list"]');
|
|
309
|
-
|
|
310
|
+
const toggle = dropdown.querySelector('.w-dropdown-toggle, [class*="dropdown-toggle"]');
|
|
311
|
+
if (!list || !toggle) return;
|
|
310
312
|
item.style.overflow = 'visible';
|
|
311
313
|
dropdown.style.overflow = 'visible';
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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() {
|
|
325
|
+
if (portalWrapper && portalWrapper.parentNode) return;
|
|
326
|
+
const rect = toggle.getBoundingClientRect();
|
|
327
|
+
portalWrapper = document.createElement('div');
|
|
328
|
+
portalWrapper.setAttribute('data-bb-marquee-dropdown-portal', 'true');
|
|
329
|
+
portalWrapper.style.cssText = 'position:fixed;left:' + rect.left + 'px;top:' + rect.top + 'px;transform:translateY(-100%);margin-top:-4px;z-index:9999;';
|
|
330
|
+
const clone = list.cloneNode(true);
|
|
331
|
+
clone.style.display = 'block';
|
|
332
|
+
portalWrapper.appendChild(clone);
|
|
333
|
+
portalWrapper.addEventListener('mouseenter', function() {});
|
|
334
|
+
portalWrapper.addEventListener('mouseleave', function() { closePortal(); });
|
|
335
|
+
document.body.appendChild(portalWrapper);
|
|
316
336
|
dropdown.classList.add('w--open');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
dropdown.addEventListener('mouseenter', function() {
|
|
340
|
+
openPortal();
|
|
317
341
|
});
|
|
318
|
-
dropdown.addEventListener('mouseleave', function() {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}, 150);
|
|
342
|
+
dropdown.addEventListener('mouseleave', function(e) {
|
|
343
|
+
if (portalWrapper && e.relatedTarget && portalWrapper.contains(e.relatedTarget)) return;
|
|
344
|
+
closePortal();
|
|
322
345
|
});
|
|
323
346
|
});
|
|
324
347
|
});
|