Reorganize JavaScript code

This commit is contained in:
Paul Nicoué 2022-04-28 14:55:36 +02:00
parent 31ddcfce63
commit 751b4c1c01

View file

@ -18,17 +18,19 @@ const navImage = document.querySelector('.home__nav-image');
const circleTypes = []; const circleTypes = [];
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// LOGIC // UTILS
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// HELPERS
// Convert rem to pixels by getting font-size CSS property // Convert rem to pixels by getting font-size CSS property
function convertRemToPixels(rem) { function convertRemToPixels(rem) {
let fontSize = parseFloat(window.getComputedStyle(document.body).getPropertyValue('font-size')); let fontSize = parseFloat(window.getComputedStyle(document.body).getPropertyValue('font-size'));
return rem * fontSize; return rem * fontSize;
} }
// ----------------------------------------------------------------------------
// LOGIC
// ----------------------------------------------------------------------------
// HOME NAVIGATION DISPLAY // // HOME NAVIGATION DISPLAY //
// Calculate navigation grid inner width // Calculate navigation grid inner width
@ -181,26 +183,19 @@ function waveNavLinksOnHover() {
} }
} }
function handleNavDisplay() {
window.addEventListener('load', function() {
curveNavLinks();
setNavItemTranslationProperty();
setNavGridDisplay();
editNavLinksOnResize();
waveNavLinksOnHover();
});
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// PROGRAM // PROGRAM
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
document.addEventListener('DOMContentLoaded', function() { // Enable CSS :active pseudo-class in Safari Mobile
document.addEventListener("touchstart", function() {},false);
document.addEventListener("touchstart", function() {},false); // Enable CSS :active pseudo-class in Safari Mobile // HOME NAVIGATION DISPLAY //
// HOME NAVIGATION DISPLAY //
handleNavDisplay();
window.addEventListener('load', function() {
curveNavLinks();
setNavItemTranslationProperty();
setNavGridDisplay();
editNavLinksOnResize();
waveNavLinksOnHover();
}); });