nunta/js/agency.js
David Miller 7db1bc641a big code cleanup
rename lib to vendor, remove deprecated LESS version, revise
package.json, load jQuery easing through npm, restructure SCSS
directory into modules, expanded code commenting and documentation
theme-wide
2017-03-31 17:05:07 -04:00

39 lines
1.2 KiB
JavaScript

(function($) {
"use strict"; // Start of use strict
// Smooth scrolling using jQuery Easing
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: (target.offset().top - 54)
}, 1000, "easeInOutExpo");
return false;
}
}
});
// Activate scrollspy to add active class to navbar items on scroll
$('body').scrollspy({
target: '#mainNav',
offset: 54
});
// Closes responsive menu when a link is clicked
$('.navbar-collapse>ul>li>a').click(function() {
$('.navbar-collapse').collapse('hide');
});
// Collapse the navbar when page is scrolled
$(window).scroll(function() {
if ($("#mainNav").offset().top > 100) {
$("#mainNav").addClass("navbar-shrink");
} else {
$("#mainNav").removeClass("navbar-shrink");
}
});
})(jQuery); // End of use strict