site.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var isTouch = window.DocumentTouch && document instanceof DocumentTouch;
  2. function scrollHeader() {
  3. // Has scrolled class on header
  4. var zvalue = $(document).scrollTop();
  5. if ( zvalue > 75 )
  6. $("#header").addClass("scrolled");
  7. else
  8. $("#header").removeClass("scrolled");
  9. }
  10. function parallaxBackground() {
  11. $('.parallax').css('background-positionY', ($(window).scrollTop() * 0.3) + 'px');
  12. }
  13. jQuery(document).ready(function($){
  14. scrollHeader();
  15. // Scroll Events
  16. if (!isTouch){
  17. $(document).scroll(function() {
  18. scrollHeader();
  19. parallaxBackground();
  20. });
  21. };
  22. // Touch scroll
  23. $(document).on({
  24. 'touchmove': function(e) {
  25. scrollHeader(); // Replace this with your code.
  26. }
  27. });
  28. //Smooth scroll to start
  29. $('#to-start').click(function(){
  30. var start_y = $('#start').position().top;
  31. var header_offset = 45;
  32. window.scroll({ top: start_y - header_offset, left: 0, behavior: 'smooth' });
  33. return false;
  34. });
  35. //Smooth scroll to top
  36. $('#to-top').click(function(){
  37. window.scroll({ top: 0, left: 0, behavior: 'smooth' });
  38. return false;
  39. });
  40. // Responsive Menu
  41. $('#toggle').click(function () {
  42. $(this).toggleClass('active');
  43. $('#overlay').toggleClass('open');
  44. $('body').toggleClass('mobile-nav-open');
  45. });
  46. // Tree Menu
  47. $(".tree").treemenu({delay:300});
  48. });