Skip to content
Snippets Groups Projects
Commit ab099610 authored by Cédric Girardot's avatar Cédric Girardot
Browse files

Refactor : Ajout de conditions dans app.js pour éviter les erreurs

Change-Id: If39a16ea8fa441e559cfae3400da99658897a48e
parent 8ead0664
No related branches found
No related tags found
No related merge requests found
......@@ -30,10 +30,16 @@ window.onload = function () {
header.classList.toggle('is-mobile-nav-open');
}
menu_hamburger.addEventListener('click', menuClick, false);
if (menu_hamburger) {
menu_hamburger.addEventListener('click', menuClick, false);
}
// Is Mobile ?
function checkMobile() {
if (!menu_hamburger) {
return;
}
let mHamburgerStyle = getComputedStyle(menu_hamburger);
if (mHamburgerStyle.display === 'none') {
......@@ -51,20 +57,28 @@ window.onload = function () {
// Changement header au scroll
let navTop = document.getElementsByClassName('nav-top')[0];
let navMiddle = document.getElementsByClassName('nav-middle')[0];
let styleNavTop = getComputedStyle(navTop);
let styleNavMiddle = getComputedStyle(navMiddle);
let navHeight = navTop.offsetHeight + parseInt(styleNavTop.marginTop) + parseInt(styleNavTop.marginBottom) +
navMiddle.offsetHeight + parseInt(styleNavMiddle.marginTop) + parseInt(styleNavMiddle.marginBottom) + 1;
isScrolled(header, navTop, navHeight, this);
if (navTop) {
let styleNavTop = getComputedStyle(navTop);
let styleNavMiddle = getComputedStyle(navMiddle);
let navHeight = navTop.offsetHeight + parseInt(styleNavTop.marginTop) + parseInt(styleNavTop.marginBottom) +
navMiddle.offsetHeight + parseInt(styleNavMiddle.marginTop) + parseInt(styleNavMiddle.marginBottom) + 1;
window.addEventListener('scroll', function () {
isScrolled(header, navTop, navHeight, this);
});
window.addEventListener('scroll', function () {
isScrolled(header, navTop, navHeight, this);
});
}
// Responsive bouton "Aide" nav
function helpButton() {
let navHelp = document.getElementsByClassName('nav-help')[0];
if (!navHelp) {
return;
}
let style = getComputedStyle(navHelp);
let helpWidth = navHelp.offsetWidth + parseInt(style.paddingLeft) + parseInt(style.paddingRight);
let helpSpace = (window.innerWidth - 1050) / 2;
......@@ -83,6 +97,10 @@ window.onload = function () {
// Margin-top main par rapport à la hauteur de la nav
function mainMargin() {
if (!header) {
return;
}
let headerHeight = header.offsetHeight;
let main = document.getElementsByTagName('main')[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment