@openeuropa/bcl-theme-joinup 1.10.8 → 1.10.9

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.
@@ -5256,5 +5256,71 @@ enableDismissTrigger(Toast);
5256
5256
 
5257
5257
  defineJQueryPlugin$1(Toast);
5258
5258
 
5259
- export { AccessibleToggle, AccordionToggle, Alert, Button, Carousel, Collapse, Dropdown, Gallery, MainNavigation, MegaMenu, Modal, Offcanvas, Popover, ScrollSpy, ScrollSpy$1 as ScrollSpyV2, Tab, Toast, Tooltip };
5259
+ const HEADER_SELECTOR = ".bcl-header";
5260
+ const TOGGLER_SELECTOR = ".bcl-navbar-toggler";
5261
+ const OFFSET_VARIABLE = "--oel-mega-menu-offset-top";
5262
+ class Header {
5263
+ scheduleUpdate = () => {
5264
+ if (this.frameRequest) {
5265
+ return;
5266
+ }
5267
+ this.frameRequest = window.requestAnimationFrame(() => {
5268
+ this.frameRequest = null;
5269
+ this.updateOffset();
5270
+ });
5271
+ };
5272
+ constructor(element) {
5273
+ this.element = element;
5274
+ this.frameRequest = null;
5275
+ this.resizeObserver = null;
5276
+ this.init();
5277
+ }
5278
+ init() {
5279
+ this.updateOffset();
5280
+ EventHandler.on(window, "resize", this.scheduleUpdate);
5281
+ EventHandler.on(window, "orientationchange", this.scheduleUpdate);
5282
+ const togglers = SelectorEngine.find(TOGGLER_SELECTOR, this.element);
5283
+ togglers.forEach(toggler => {
5284
+ // Some layouts move the header when the nav toggler expands; keep offset in sync.
5285
+ EventHandler.on(toggler, "click", this.scheduleUpdate);
5286
+ });
5287
+ }
5288
+ updateOffset() {
5289
+ if (!this.element) {
5290
+ return;
5291
+ }
5292
+ const rect = this.element.getBoundingClientRect();
5293
+ const offset = Math.max(0, rect.top);
5294
+ const value = `${offset}px`;
5295
+ if (this.element.style.getPropertyValue(OFFSET_VARIABLE) === value) {
5296
+ return;
5297
+ }
5298
+ this.element.style.setProperty(OFFSET_VARIABLE, value);
5299
+ }
5300
+ static init(root) {
5301
+ if (typeof document === "undefined" || typeof window === "undefined") {
5302
+ return;
5303
+ }
5304
+ const resolvedRoot = root || document;
5305
+ const context = resolvedRoot instanceof Element ? resolvedRoot : resolvedRoot.documentElement || document.documentElement;
5306
+ const headers = SelectorEngine.find(HEADER_SELECTOR, context);
5307
+ headers.forEach(headerElement => {
5308
+ if (headerElement.dataset.headerOffsetInitialized === "true") {
5309
+ return;
5310
+ }
5311
+ headerElement.dataset.headerOffsetInitialized = "true";
5312
+ new Header(headerElement);
5313
+ });
5314
+ }
5315
+ }
5316
+ if (typeof document !== "undefined") {
5317
+ const initializeHeaderOffset = () => Header.init();
5318
+ if (document.readyState === "loading") {
5319
+ document.addEventListener("DOMContentLoaded", initializeHeaderOffset);
5320
+ } else {
5321
+ initializeHeaderOffset();
5322
+ }
5323
+ }
5324
+
5325
+ export { AccessibleToggle, AccordionToggle, Alert, Button, Carousel, Collapse, Dropdown, Gallery, Header, MainNavigation, MegaMenu, Modal, Offcanvas, Popover, ScrollSpy, ScrollSpy$1 as ScrollSpyV2, Tab, Toast, Tooltip };
5260
5326
  //# sourceMappingURL=oe-bcl-joinup.esm.js.map