Blinking fixed header in site with scrolling animation

后端 未结 6 579
面向向阳花
面向向阳花 2020-12-16 23:24

So I\'m putting a website together which will have a few css3 animations triggered on the scroll event. About halfway through writing the scrolling animations, I\'m noticing

6条回答
  •  一个人的身影
    2020-12-17 00:19

    I fixed this by changing the document.body.scrollTop and document.documentElement.scrollTop to > 1 instead of > 50 or > 25:

    window.onscroll = function () {
        // Change the scrollTop conditions here.
        if (document.body.scrollTop > 1 || document.documentElement.scrollTop > 1) {
            yourTopBarInnerElement.style.display = "none";
        } else {
            yourTopBarInnerElement.style.display = "block";
        };
    };
    

    It works for me at least.

提交回复
热议问题