export function scrollToTop(){
    let scrollToTop = document.querySelector('.scroll-to-top');
    if(scrollToTop){
        let scrollTimeout = null;
        scrollToTop.addEventListener('click', function(){
            window.scrollTo({ top: 0, behavior: 'smooth' });
        })
        window.addEventListener('scroll', function(){
            if (scrollTimeout) {
                clearInterval(scrollTimeout);
            }
            scrollTimeout = setTimeout(() => {
                if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
                    scrollToTop.classList.add('show-scroll');
                } else {
                    scrollToTop.classList.remove('show-scroll');
                }
            }, 200);
        });

    }
}