index-website-static/assets/js/onload.js
Julie Blanc 32f45ceeca
All checks were successful
Deploy / Deploy to pre-production (push) Successful in 5s
banner on mobile
2025-12-24 16:00:47 +01:00

54 lines
1.2 KiB
JavaScript

import { headerToggle, headerScrollVisibility } from './header.js';
import { copyLink } from './share.js';
import { btnSticky } from './mobile-sticky.js';
const responsiveMedium = 1080;
const responsiveSmall = 768;
// TEMP, with includeHTML() --------------------------------------
window.onload = async function () {
await runIncludeHTML();
initAfterLoad();
};
function runIncludeHTML() {
if (typeof includeHTML === "function") {
const result = includeHTML();
if (result instanceof Promise) {
return result;
}
}
return Promise.resolve();
}
/// INIT --------------------------------------------------------
// Note: une fois que IncludeHTML() est supprimé, on peut supprimer tout le temp au dessus
// remplacer `function initAfterLoad()` par ↓
// window.onload = async function () { }
function initAfterLoad() {
headerToggle();
headerScrollVisibility();
copyLink();
btnSticky(responsiveSmall);
}
function responsiveLoader() {
let isLoaded = false;
function checkResize() {
if (window.innerWidth < responsiveSmall && !isLoaded) {
// other functions qui ne chargent que pour la version mobile ...
isLoaded = true;
}
}
checkResize();
window.addEventListener('resize', checkResize);
}