feat(theme/book): Scroll to top when clicking the page title (#613)

Common pattern, especially on mobile devices where the page can be quite long.
This commit is contained in:
Sorin Davidoi 2018-02-09 11:34:18 +01:00 committed by Michael Bryan
parent 2989096188
commit 990daceed5
3 changed files with 10 additions and 0 deletions

View File

@ -220,6 +220,7 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
overflow: hidden; overflow: hidden;
-o-text-overflow: ellipsis; -o-text-overflow: ellipsis;
text-overflow: ellipsis; text-overflow: ellipsis;
cursor: pointer;
} }
.nav-chapters { .nav-chapters {
font-size: 2.5em; font-size: 2.5em;

View File

@ -522,6 +522,14 @@ function playpen_text(playpen) {
}); });
})(); })();
(function scrollToTop () {
var menuTitle = document.querySelector('.menu-title');
menuTitle.addEventListener('click', function () {
document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' });
});
})();
(function autoHideMenu() { (function autoHideMenu() {
var menu = document.getElementById('menu-bar'); var menu = document.getElementById('menu-bar');

View File

@ -38,4 +38,5 @@ html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-conta
white-space: nowrap white-space: nowrap
overflow: hidden overflow: hidden
text-overflow: ellipsis text-overflow: ellipsis
cursor: pointer;
} }