39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
document.documentElement.classList.remove('no-js');
|
|
document.documentElement.classList.add('js');
|
|
|
|
function initStickyHeader() {
|
|
var header = document.querySelector('#header');
|
|
if (!header) return;
|
|
function updateHeader() {
|
|
header.classList.toggle('sticky', window.scrollY > 1);
|
|
}
|
|
updateHeader();
|
|
window.addEventListener('scroll', updateHeader, { passive: true });
|
|
}
|
|
|
|
function initNavigation() {
|
|
var panel = document.querySelector('#fragrance-navigation');
|
|
if (!panel || !window.bootstrap || !window.bootstrap.Offcanvas) return;
|
|
panel.querySelectorAll('a[href*="#"]').forEach(function (link) {
|
|
link.addEventListener('click', function () {
|
|
var instance = window.bootstrap.Offcanvas.getInstance(panel);
|
|
if (instance) instance.hide();
|
|
});
|
|
});
|
|
}
|
|
|
|
function initTheme() {
|
|
initStickyHeader();
|
|
initNavigation();
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', initTheme);
|
|
} else {
|
|
initTheme();
|
|
}
|
|
})();
|