// Check if JavaScript is running properly
console.log("JavaScript is running...");

// ----------------------------------------------------------------------------------------------------

// Fade Up Behaviour
let fadeups = document.querySelectorAll('.custom-fadeUp');

function fadeUp() {
    fadeups.forEach(fadeup => {
        let viewportHeight = window.innerHeight - 75;
        let topEdge = fadeup.getBoundingClientRect().top;
        if (viewportHeight > topEdge) {
            fadeup.classList.add('in-view');
        } else {
            fadeup.classList.remove('in-view');
        }
    })
}

// ----------------------------------------------------------------------------------------------------

// Fade Out Behaviour

let fadeOuts = document.querySelector('.custom-fadeOut');

function fadeOut() {
    let distance = window.scrollY;
    fadeOuts.style.opacity =  (distance * -0.0039) + 1;
}

// ----------------------------------------------------------------------------------------------------

// A function to call all the functions
function allTheFunctions() {
    fadeUp();
    fadeOut();
}

allTheFunctions();

// All the functions are called whenever screen is rezied on scrolled through
window.addEventListener('resize', allTheFunctions);
window.addEventListener('scroll', allTheFunctions);