nunta/js/agency.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

(function($) {
"use strict"; // Start of use strict
2017-04-01 00:16:22 +02:00
// 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({
2016-11-30 03:03:56 +01:00
target: '#mainNav',
offset: 54
});
// Closes responsive menu when a link is clicked
2017-03-06 17:21:55 +01:00
$('.navbar-collapse>ul>li>a').click(function() {
$('.navbar-collapse').collapse('hide');
});
// Collapse the navbar when page is scrolled
2016-11-30 03:03:56 +01:00
$(window).scroll(function() {
if ($("#mainNav").offset().top > 100) {
$("#mainNav").addClass("navbar-shrink");
} else {
$("#mainNav").removeClass("navbar-shrink");
}
2016-11-30 03:03:56 +01:00
});
})(jQuery); // End of use strict