From a6f2ed8c6c70d51953c2b6f1c1ce54b113ede332 Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Wed, 4 Dec 2019 22:27:43 +0100 Subject: [PATCH] Improved search on mobile --- _sass/search.scss | 8 ++++++++ assets/js/just-the-docs.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/_sass/search.scss b/_sass/search.scss index 10eb5b2..256eb7f 100644 --- a/_sass/search.scss +++ b/_sass/search.scss @@ -248,6 +248,14 @@ transition: opacity ease 200ms, width 0s, height 0s; } + body { + overflow-y: hidden; + + @include mq(md) { + overflow-y: scroll; + } + } + @include mq(md) { .main { position: absolute; diff --git a/assets/js/just-the-docs.js b/assets/js/just-the-docs.js index 1d4277c..49479f6 100644 --- a/assets/js/just-the-docs.js +++ b/assets/js/just-the-docs.js @@ -111,6 +111,7 @@ function initSearch() { var docs = docs; var searchInput = document.getElementById('search-input'); var searchResults = document.getElementById('search-results'); + var mainHeader = document.getElementById('main-header'); function clearResults() { searchResults.innerHTML = ''; @@ -140,6 +141,7 @@ function initSearch() { }); if (results.length > 0) { + window.scroll(0, window.scrollY + mainHeader.getBoundingClientRect().top); document.documentElement.classList.add('search-active'); var resultsList = document.createElement('ul');