Skip to content

Commit

Permalink
Merge pull request #351 from Xpirix/fix_search_bar_on_mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux authored Jul 19, 2024
2 parents 9c5f898 + c4553f3 commit dd26ae9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion themes/hugo-bulma-blocks-theme/assets/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,28 @@ document.addEventListener("DOMContentLoaded", () => {
});

var prevScrollpos = window.scrollY;
var isTyping = false;

// Get the input element
var searchInput = document.getElementById("search-query");

// Add focus and blur event listeners to the input
searchInput.addEventListener("focus", function() {
isTyping = true;
});

searchInput.addEventListener("blur", function() {
isTyping = false;
});

window.onscroll = function () {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {

if (prevScrollpos > currentScrollPos || isTyping) {
// Show the news&search bar
document.getElementById("context").style.top = "4rem";
} else {
// Hide the news&search bar
document.getElementById("context").style.top = "-2em";
}
prevScrollpos = currentScrollPos;
Expand Down

0 comments on commit dd26ae9

Please sign in to comment.