Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

247 righe
3.3 KiB

  1. /* JS Document */
  2. /******************************
  3. [Table of Contents]
  4. 1. Vars and Inits
  5. 2. Set Header
  6. 3. Init Menu
  7. 4. Init Tabs
  8. 5. Init Flickr
  9. 6. Init Gallery
  10. 7. Init Sidebar Slider
  11. 8. Init Parallax
  12. ******************************/
  13. $(document).ready(function()
  14. {
  15. "use strict";
  16. /*
  17. 1. Vars and Inits
  18. */
  19. var ctrl = new ScrollMagic.Controller();
  20. var header = $('.header');
  21. var menuActive = false;
  22. var hamb = $('.hamburger_container');
  23. var menu = $('.fs_menu_container');
  24. var hambIcon = $('.hamburger_icon');
  25. setHeader();
  26. $(window).on('resize', function()
  27. {
  28. setHeader();
  29. });
  30. $(document).on('scroll', function()
  31. {
  32. setHeader();
  33. });
  34. initMenu();
  35. initTabs();
  36. initFlickr();
  37. initGallery();
  38. initSidebarSlider();
  39. initParallax();
  40. /*
  41. 2. Set Header
  42. */
  43. function setHeader()
  44. {
  45. if(window.innerWidth < 992)
  46. {
  47. if($(window).scrollTop() > 100)
  48. {
  49. header.css({'height':"80"});
  50. }
  51. else
  52. {
  53. header.css({'height':"110"});
  54. }
  55. }
  56. else
  57. {
  58. if($(window).scrollTop() > 100)
  59. {
  60. header.css({'height':"80"});
  61. }
  62. else
  63. {
  64. header.css({'height':"110"});
  65. }
  66. }
  67. if(window.innerWidth > 991 && menuActive)
  68. {
  69. closeMenu();
  70. }
  71. }
  72. /*
  73. 3. Init Menu
  74. */
  75. function initMenu()
  76. {
  77. if($('.hamburger_container').length)
  78. {
  79. hamb.on('click', function()
  80. {
  81. if(!menuActive)
  82. {
  83. openMenu();
  84. }
  85. else
  86. {
  87. closeMenu();
  88. }
  89. });
  90. }
  91. }
  92. function openMenu()
  93. {
  94. menu.addClass('active');
  95. setTimeout(function()
  96. {
  97. hambIcon.addClass('active');
  98. },500);
  99. menuActive = true;
  100. }
  101. function closeMenu()
  102. {
  103. menu.removeClass('active');
  104. setTimeout(function()
  105. {
  106. hambIcon.removeClass('active');
  107. },500);
  108. menuActive = false;
  109. }
  110. /*
  111. 4. Init Tabs
  112. */
  113. function initTabs()
  114. {
  115. if($('.tabs').length)
  116. {
  117. var tabs = $('.tabs li');
  118. var tabContainers = $('.tab_container');
  119. tabs.each(function()
  120. {
  121. var tab = $(this);
  122. var tab_id = tab.data('active-tab');
  123. tab.on('click', function()
  124. {
  125. if(!tab.hasClass('active'))
  126. {
  127. tabs.removeClass('active');
  128. tabContainers.removeClass('active');
  129. tab.addClass('active');
  130. $('#' + tab_id).addClass('active');
  131. }
  132. });
  133. });
  134. }
  135. }
  136. /*
  137. 5. Init Flickr
  138. */
  139. function initFlickr()
  140. {
  141. if($('.flickr_gallery').length)
  142. {
  143. setTimeout(function()
  144. {
  145. $('.colorbox').colorbox();
  146. },1000);
  147. }
  148. }
  149. /*
  150. 6. Init Gallery
  151. */
  152. function initGallery()
  153. {
  154. if($('.gallery_item').length)
  155. {
  156. $('.gallery_item a').colorbox();
  157. }
  158. }
  159. /*
  160. 7. Init Gallery
  161. */
  162. function initSidebarSlider()
  163. {
  164. if($('.sidebar_slider').length)
  165. {
  166. var sidebarSlider = $('.sidebar_slider');
  167. sidebarSlider.owlCarousel({
  168. items:1,
  169. autoplay:true,
  170. loop:true,
  171. autoplaySpeed:500,
  172. dots:false,
  173. nav:false
  174. });
  175. }
  176. }
  177. /*
  178. 8. Init Parallax
  179. */
  180. function initParallax()
  181. {
  182. if($('.prlx_parent').length && $('.prlx').length)
  183. {
  184. var elements = $('.prlx_parent');
  185. elements.each(function()
  186. {
  187. var ele = this;
  188. var bcg = $(ele).find('.prlx');
  189. var slideParallaxScene = new ScrollMagic.Scene({
  190. triggerElement: ele,
  191. triggerHook: 1,
  192. duration: "200%"
  193. })
  194. .setTween(TweenMax.from(bcg, 1, {y: '-30%', ease:Power0.easeNone}))
  195. .addTo(ctrl);
  196. });
  197. }
  198. }
  199. });