let lastScrollPosition = 0;
const headerWrapper = document.querySelector('#header-wrapper'); // Changed selector
const scrollThreshold = 100;

function getTranslateValue() {
    return window.innerWidth <= 477 ? -38 : -60;
}

window.addEventListener('scroll', () => {
    const currentScrollPosition = window.pageYOffset || document.documentElement.scrollTop;
    if (currentScrollPosition > scrollThreshold) {
        // Scrolling down
        if (currentScrollPosition > lastScrollPosition) {
            headerWrapper.style.transform = `translateY(${getTranslateValue()}px)`;
        }
        // Scrolling up
        else {
            headerWrapper.style.transform = 'translateY(0)';
        }
    } else {
        // Reset position when above threshold
        headerWrapper.style.transform = 'translateY(0)';
    }
    lastScrollPosition = currentScrollPosition;
});

// Handle resize events
window.addEventListener('resize', () => {
    if (lastScrollPosition > scrollThreshold) {
        headerWrapper.style.transform = `translateY(${getTranslateValue()}px)`;
    }
});

Terms of Service

SMS Terms of Service

By opting into SMS from a web form or other medium, you are agreeing to receive SMS messages from Shift Rite Transmissions. This includes SMS messages for customer care. Message frequency varies. Message and data rates may apply. See privacy policy at https://shiftritertransmissions.com/privacy. Message HELP for help. Reply STOP to any message to opt out.

Send us a message

  • This field is for validation purposes and should be left unchanged.
  • If applicable