diff --git a/source/_js/post-bottom-bar.js b/source/_js/post-bottom-bar.js index 20fd5e916..9648f02e1 100644 --- a/source/_js/post-bottom-bar.js +++ b/source/_js/post-bottom-bar.js @@ -12,8 +12,10 @@ this.$postBottomBar = $('.post-bottom-bar'); this.$postFooter = $('.post-actions-wrap'); this.$header = $('#header'); - this.delta = 1; + this.delta = 15; this.lastScrollTop = 0; + this.lastScrollDownPos = 0 + this.lastScrollUpPos = 0 }; PostBottomBar.prototype = { @@ -47,17 +49,26 @@ swipePostBottomBar: function() { var scrollTop = $(window).scrollTop(); var postFooterOffsetTop = this.$postFooter.offset().top; - // show bottom bar - // if the user scrolled upwards more than `delta` - // and `post-footer` div isn't visible - if (this.lastScrollTop > scrollTop && - (postFooterOffsetTop + this.$postFooter.height() > scrollTop + $(window).height() || - postFooterOffsetTop < scrollTop + this.$header.height())) { - this.$postBottomBar.slideDown(); + + // scrolling up + if (this.lastScrollTop > scrollTop) { + // show bottom bar + // if the user scrolled upwards more than `delta` + // and `post-footer` div isn't visible + if (Math.abs(this.lastScrollDownPos - scrollTop) > this.delta && + (postFooterOffsetTop + this.$postFooter.height() > scrollTop + $(window).height() || + postFooterOffsetTop < scrollTop + this.$header.height())) { + this.$postBottomBar.slideDown(); + this.lastScrollUpPos = scrollTop + } } - else { + + // scrolling down + if (scrollTop > this.lastScrollUpPos + this.delta) { this.$postBottomBar.slideUp(); + this.lastScrollDownPos = scrollTop } + this.lastScrollTop = scrollTop; } };