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.

153 lines
2.0 KiB

  1. /* JS Document */
  2. /******************************
  3. [Table of Contents]
  4. 1. Vars and Inits
  5. 2. Set Header
  6. 2. Init Menu
  7. 3. Init Parallax
  8. ******************************/
  9. $(document).ready(function()
  10. {
  11. "use strict";
  12. /*
  13. 1. Vars and Inits
  14. */
  15. var ctrl = new ScrollMagic.Controller();
  16. var header = $('.header');
  17. var menuActive = false;
  18. var hamb = $('.hamburger_container');
  19. var menu = $('.fs_menu_container');
  20. var hambIcon = $('.hamburger_icon');
  21. setHeader();
  22. $(window).on('resize', function()
  23. {
  24. setHeader();
  25. });
  26. $(document).on('scroll', function()
  27. {
  28. setHeader();
  29. });
  30. initMenu();
  31. initParallax();
  32. /*
  33. 2. Set Header
  34. */
  35. function setHeader()
  36. {
  37. if(window.innerWidth < 992)
  38. {
  39. if($(window).scrollTop() > 100)
  40. {
  41. header.css({'height':"80"});
  42. }
  43. else
  44. {
  45. header.css({'height':"110"});
  46. }
  47. }
  48. else
  49. {
  50. if($(window).scrollTop() > 100)
  51. {
  52. header.css({'height':"80"});
  53. }
  54. else
  55. {
  56. header.css({'height':"110"});
  57. }
  58. }
  59. if(window.innerWidth > 991 && menuActive)
  60. {
  61. closeMenu();
  62. }
  63. }
  64. /*
  65. 2. Init Menu
  66. */
  67. function initMenu()
  68. {
  69. if($('.hamburger_container').length)
  70. {
  71. hamb.on('click', function()
  72. {
  73. if(!menuActive)
  74. {
  75. openMenu();
  76. }
  77. else
  78. {
  79. closeMenu();
  80. }
  81. });
  82. }
  83. }
  84. function openMenu()
  85. {
  86. menu.addClass('active');
  87. setTimeout(function()
  88. {
  89. hambIcon.addClass('active');
  90. },500);
  91. menuActive = true;
  92. }
  93. function closeMenu()
  94. {
  95. menu.removeClass('active');
  96. setTimeout(function()
  97. {
  98. hambIcon.removeClass('active');
  99. },500);
  100. menuActive = false;
  101. }
  102. /*
  103. 3. Init Parallax
  104. */
  105. function initParallax()
  106. {
  107. if($('.prlx_parent').length && $('.prlx').length)
  108. {
  109. var elements = $('.prlx_parent');
  110. elements.each(function()
  111. {
  112. var ele = this;
  113. var bcg = $(ele).find('.prlx');
  114. var slideParallaxScene = new ScrollMagic.Scene({
  115. triggerElement: ele,
  116. triggerHook: 1,
  117. duration: "200%"
  118. })
  119. .setTween(TweenMax.from(bcg, 1, {y: '-30%', ease:Power0.easeNone}))
  120. .addTo(ctrl);
  121. });
  122. }
  123. }
  124. });