diff --git a/src/theme/book.css b/src/theme/book.css index c86007fa..36dc818e 100644 --- a/src/theme/book.css +++ b/src/theme/book.css @@ -144,6 +144,7 @@ table thead td { max-width: 100%; } #menu-bar { + position: -webkit-sticky; position: sticky; top: 0; z-index: 101; diff --git a/src/theme/book.js b/src/theme/book.js index dccdc4f6..f686af44 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -510,26 +510,25 @@ function playpen_text(playpen) { })(); (function autoHideMenu() { - var scrollingContainer = document.querySelector('html'); var menu = document.getElementById('menu-bar'); - var previousScrollTop = scrollingContainer.scrollTop; + var previousScrollTop = document.scrollingElement.scrollTop; document.addEventListener('scroll', function () { - if (menu.classList.contains('folded') && scrollingContainer.scrollTop < previousScrollTop) { + if (menu.classList.contains('folded') && document.scrollingElement.scrollTop < previousScrollTop) { menu.classList.remove('folded'); - } else if (!menu.classList.contains('folded') && scrollingContainer.scrollTop > previousScrollTop) { + } else if (!menu.classList.contains('folded') && document.scrollingElement.scrollTop > previousScrollTop) { menu.classList.add('folded'); } - if (!menu.classList.contains('bordered') && scrollingContainer.scrollTop > 0) { + if (!menu.classList.contains('bordered') && document.scrollingElement.scrollTop > 0) { menu.classList.add('bordered'); } - if (menu.classList.contains('bordered') && scrollingContainer.scrollTop === 0) { + if (menu.classList.contains('bordered') && document.scrollingElement.scrollTop === 0) { menu.classList.remove('bordered'); } - previousScrollTop = scrollingContainer.scrollTop; + previousScrollTop = document.scrollingElement.scrollTop; }, { passive: true }); })(); diff --git a/src/theme/stylus/menu.styl b/src/theme/stylus/menu.styl index 458d9bdb..eae9469a 100644 --- a/src/theme/stylus/menu.styl +++ b/src/theme/stylus/menu.styl @@ -1,4 +1,5 @@ #menu-bar { + position: -webkit-sticky position: sticky top: 0 z-index: 101