Personal portfolio website created with bootstrap.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

  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 - 48)
  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: 54
  24. });
  25. // Collapse the navbar when page is scrolled
  26. $(window).scroll(function() {
  27. if ($("#mainNav").offset().top > 100) {
  28. $("#mainNav").addClass("navbar-shrink");
  29. } else {
  30. $("#mainNav").removeClass("navbar-shrink");
  31. }
  32. });
  33. // Floating label headings for the contact form
  34. $(function() {
  35. $("body").on("input propertychange", ".floating-label-form-group", function(e) {
  36. $(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
  37. }).on("focus", ".floating-label-form-group", function() {
  38. $(this).addClass("floating-label-form-group-with-focus");
  39. }).on("blur", ".floating-label-form-group", function() {
  40. $(this).removeClass("floating-label-form-group-with-focus");
  41. });
  42. });
  43. })(jQuery); // End of use strict