mirror of
https://github.com/DigitalDesignDude/DSGM-Resource-Site.git
synced 2025-06-18 13:45:40 -04:00
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
//Make Navbar fixed to top of screen after scrolling past header
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
window.addEventListener('scroll', function () {
|
|
if (window.scrollY > 253) {
|
|
document.getElementById('site-navigation').classList.add('nav-fixed');
|
|
// add padding top to show content behind navbar
|
|
navbar_height = document.querySelector('.navbar').offsetHeight;
|
|
document.body.style.paddingTop = navbar_height + 'px';
|
|
} else {
|
|
document.getElementById('site-navigation').classList.remove('nav-fixed');
|
|
// remove padding top from body
|
|
document.body.style.paddingTop = '0';
|
|
}
|
|
});
|
|
});
|
|
// DOMContentLoaded end
|
|
|
|
|
|
|
|
//Smooth Scrolling
|
|
$(document).ready(function () {
|
|
// Add smooth scrolling to all links
|
|
$("a").on('click', function (event) {
|
|
|
|
// Make sure this.hash has a value before overriding default behavior
|
|
if (this.hash !== "") {
|
|
// Prevent default anchor click behavior - commented out to allow jumping to anchors on other pages.
|
|
//event.preventDefault();
|
|
|
|
// Store hash
|
|
var hash = this.hash;
|
|
|
|
//Store extra offset value
|
|
var offsetY = 60
|
|
|
|
// Using jQuery's animate() method to add smooth page scroll
|
|
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
|
|
$('html, body').animate({
|
|
scrollTop: $(hash).offset().top - offsetY //
|
|
}, 800, function () {
|
|
|
|
// Add hash (#) to URL when done scrolling (default click behavior)
|
|
window.location.hash = hash;
|
|
});
|
|
} // End if
|
|
});
|
|
});
|
|
|
|
|
|
//AutoPlay Youtube Video Banner on Mobile Devices
|