@bebranded/bb-contents 1.1.17 → 1.1.18
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 +36 -7
- 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.18
|
|
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.18';
|
|
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
|
-
//
|
|
300
|
+
// Dropdown en portal (fixed) au-dessus du toggle, aligné en haut à droite, pour éviter le clipping du marquee
|
|
301
301
|
_enableMarqueeDropdowns: function(block) {
|
|
302
302
|
if (!block || !block.querySelectorAll) return;
|
|
303
303
|
const items = block.querySelectorAll('.bb-marquee_item, [role="listitem"]');
|
|
@@ -306,14 +306,43 @@
|
|
|
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
|
-
|
|
313
|
+
let portalWrapper = null;
|
|
314
|
+
|
|
315
|
+
function closePortal() {
|
|
316
|
+
if (portalWrapper && portalWrapper.parentNode) {
|
|
317
|
+
portalWrapper.parentNode.removeChild(portalWrapper);
|
|
318
|
+
}
|
|
319
|
+
portalWrapper = null;
|
|
320
|
+
dropdown.classList.remove('w--open');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function openPortal() {
|
|
324
|
+
if (portalWrapper && portalWrapper.parentNode) return;
|
|
325
|
+
const rect = toggle.getBoundingClientRect();
|
|
326
|
+
portalWrapper = document.createElement('div');
|
|
327
|
+
portalWrapper.setAttribute('data-bb-marquee-dropdown-portal', 'true');
|
|
328
|
+
portalWrapper.style.cssText =
|
|
329
|
+
'position:fixed;right:' + (window.innerWidth - rect.right) + 'px;top:' + rect.top + 'px;' +
|
|
330
|
+
'transform:translateY(-100%);margin-top:-4px;z-index:9999;background:transparent;';
|
|
331
|
+
const clone = list.cloneNode(true);
|
|
332
|
+
clone.style.display = 'block';
|
|
333
|
+
portalWrapper.appendChild(clone);
|
|
334
|
+
portalWrapper.addEventListener('mouseenter', function() {});
|
|
335
|
+
portalWrapper.addEventListener('mouseleave', function() { closePortal(); });
|
|
336
|
+
document.body.appendChild(portalWrapper);
|
|
313
337
|
dropdown.classList.add('w--open');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
dropdown.addEventListener('mouseenter', function() {
|
|
341
|
+
openPortal();
|
|
314
342
|
});
|
|
315
|
-
dropdown.addEventListener('mouseleave', function() {
|
|
316
|
-
|
|
343
|
+
dropdown.addEventListener('mouseleave', function(e) {
|
|
344
|
+
if (portalWrapper && e.relatedTarget && portalWrapper.contains(e.relatedTarget)) return;
|
|
345
|
+
closePortal();
|
|
317
346
|
});
|
|
318
347
|
});
|
|
319
348
|
});
|