export default (() => {
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault()

            const element = document.querySelector(this.getAttribute('href'))
            let offset = - getOffset()

            const y = element.getBoundingClientRect().top + window.pageYOffset + offset;

            window.scrollTo({
                top: y,
                behavior: 'smooth',
            })

        });
    });

    function getOffset() {
        let height = document.querySelector('.main-header').offsetHeight + 30
        return height
    }
})()