greyscale.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (function($) {
  2. "use strict"; // Start of use strict
  3. // Smooth scrolling using jQuery easing
  4. $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
  5. if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  6. var target = $(this.hash);
  7. target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  8. if (target.length) {
  9. $('html, body').animate({
  10. scrollTop: (target.offset().top - 70)
  11. }, 1000, "easeInOutExpo");
  12. return false;
  13. }
  14. }
  15. });
  16. // Closes responsive menu when a scroll trigger link is clicked
  17. $('.js-scroll-trigger').click(function() {
  18. $('.navbar-collapse').collapse('hide');
  19. });
  20. // Activate scrollspy to add active class to navbar items on scroll
  21. $('body').scrollspy({
  22. target: '#mainNav',
  23. offset: 100
  24. });
  25. // Collapse Navbar
  26. var navbarCollapse = function() {
  27. if ($("#mainNav").offset().top > 100) {
  28. $("#mainNav").addClass("navbar-shrink");
  29. } else {
  30. $("#mainNav").removeClass("navbar-shrink");
  31. }
  32. };
  33. // Collapse now if page is not at top
  34. navbarCollapse();
  35. // Collapse the navbar when page is scrolled
  36. $(window).scroll(navbarCollapse);
  37. })(jQuery); // End of use strict