Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
747 B
1
Indexable
Never
const scrollPosition = ref<number>(0);

// On définit un pas pour enclencher l'ajout / suppresion de la classe scroll
const onScroll = (): void => {
    const burgerMenu = document.querySelector(".burger-menu");
    if (!burgerMenu?.classList.contains("open")) {
        if ((lastScrollPosition.value - scrollPosition.value) < -75) {
            refHeader?.value?.classList.add("scroll");
            lastScrollPosition.value = scrollPosition.value;
        } else if ((lastScrollPosition.value - scrollPosition.value) > 75) {
            refHeader?.value?.classList.remove("scroll");
            lastScrollPosition.value = scrollPosition.value;
        }
        scrollPosition.value = document.documentElement.scrollTop;
    }
};
Leave a Comment