Fix behaviour of auto-hide header (#78)
Fixed #76: On mobile environment (iOS Safari), when the page scrolls to the top then bounce back, the header (bottom bar) turns to hide unexpectedly. Fixed it by forcing `currentScrollPosition` not a negative value.
This commit is contained in:
1 parent
6cee5adc69
commit
c2e02c5dff
3 files changed
+1
-11
No files matched your search
+1
-1
@@ -34,7 +34,7 @@ let header = document.getElementById('site-header');
|
||||
let lastScrollPosition = window.pageYOffset;
|
||||
|
||||
const autoHideHeader = () => {
|
||||
let currentScrollPosition = window.pageYOffset;
|
||||
let currentScrollPosition = Math.max(window.pageYOffset, 0);
|
||||
if (currentScrollPosition > lastScrollPosition) {
|
||||
header.classList.remove('slideInUp');
|
||||
header.classList.add('slideOutDown');
|
||||
|
||||
Reference in new issue
Block a user