Fix Nav-Bar when link to section of page (#486)

This commit is contained in:
Tobias Mühlberger 2022-01-04 05:43:27 +01:00 committed by GitHub
parent bc0b69d726
commit d1bc8e2f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,13 +1,6 @@
"use strict";
(function ($) {
jQuery(document).ready(function () {
// change navbar style on scroll
// ==================================================
// When the user scrolls down 80px from the top of the document, resize the navbar's padding and the logo's font size
// $.onscroll = function() {scrollFunction()};
$(document).scroll(function () {
const updateNavBar = () => {
if ($(document).scrollTop() > 40) {
$('#top-navbar').removeClass('initial-navbar');
$('#top-navbar').addClass('final-navbar shadow');
@ -36,6 +29,17 @@
$('#logo').attr("src", logoURL);
}
}
};
(function ($) {
jQuery(document).ready(function () {
// change navbar style on scroll
// ==================================================
// When the user scrolls down 80px from the top of the document, resize the navbar's padding and the logo's font size
// $.onscroll = function() {scrollFunction()};
$(document).scroll(function () {
updateNavBar();
});
// Creates a click handler to collapse the navigation when
@ -46,6 +50,8 @@
$('.navbar-collapse').collapse('hide');
});
}
updateNavBar();
});
})(jQuery);