creative.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 - 72)
  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: 75
  24. });
  25. // Collapse Navbar
  26. var navbarCollapse = function() {
  27. if ($("#mainNav").offset().top > 100) {
  28. $("#mainNav").addClass("navbar-scrolled");
  29. } else {
  30. $("#mainNav").removeClass("navbar-scrolled");
  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. // Magnific popup calls
  38. $('#portfolio').magnificPopup({
  39. delegate: 'a',
  40. type: 'image',
  41. tLoading: 'Loading image #%curr%...',
  42. mainClass: 'mfp-img-mobile',
  43. gallery: {
  44. enabled: true,
  45. navigateByImgClick: true,
  46. preload: [0, 1]
  47. },
  48. image: {
  49. tError: '<a href="%url%">The image #%curr%</a> could not be loaded.'
  50. }
  51. });
  52. })(jQuery); // End of use strict