From c2e02c5dff0ce5372ec81767c9224054a05a0002 Mon Sep 17 00:00:00 2001 From: Akio Taniguchi Date: Sat, 22 Jun 2019 18:27:00 +0900 Subject: 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. --- assets/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'assets/js') diff --git a/assets/js/main.js b/assets/js/main.js index 5f0a47c..d18cbaa 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -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'); -- cgit v1.2.3