Scroll event buggy on iphone

I have an header element that I am changing to be position: sticky on up-scroll and position: static on down-scroll. This code is working fine on desktop, but is causing the element to appear, then disappear for a millisecond on iphone, then reappear.

function scrollHeader() {
             var st = window.pageYOffset || document.documentElement.scrollTop;
             if (st > lastScrollTop){
                 // downscroll code
             } else {
                 // upscroll code
             lastScrollTop = st;

         var lastScrollTop = 0;
         window.addEventListener("scroll", _.throttle(scrollHeader, 400));

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.