Skip to content

Commit

Permalink
Header hiding bug (Shopify#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoboludo authored Aug 26, 2021
1 parent 6e4d4bc commit 79cef6f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions sections/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -465,24 +465,25 @@
onScroll() {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;

if (this.preventReveal) {
window.clearTimeout(this.isScrolling);
if (scrollTop > this.currentScrollTop && scrollTop > this.headerBounds.bottom) {
requestAnimationFrame(this.hide.bind(this));
} else if (scrollTop < this.currentScrollTop && scrollTop > this.headerBounds.bottom) {
if (!this.preventReveal) {
requestAnimationFrame(this.reveal.bind(this));
} else {
window.clearTimeout(this.isScrolling);

this.isScrolling = setTimeout(() => {
this.preventReveal = false;
}, 66);
this.isScrolling = setTimeout(() => {
this.preventReveal = false;
}, 66);

requestAnimationFrame(this.hide.bind(this));
} else {
if (scrollTop > this.currentScrollTop && scrollTop > this.headerBounds.bottom) {
requestAnimationFrame(this.hide.bind(this));
} else if (scrollTop < this.currentScrollTop && scrollTop > this.headerBounds.bottom) {
requestAnimationFrame(this.reveal.bind(this));
} else if (scrollTop <= this.headerBounds.top) {
requestAnimationFrame(this.reset.bind(this));
}
} else if (scrollTop <= this.headerBounds.top) {
requestAnimationFrame(this.reset.bind(this));
}


this.currentScrollTop = scrollTop;
}

Expand Down

0 comments on commit 79cef6f

Please sign in to comment.