Advertisement
MikkoDC

Kahua Form

Feb 4th, 2025
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. (function($) {
  2. function initializeAnims() {
  3.  
  4. const footerForms = $('.module--footer_form');
  5.  
  6. console.log(`Total .module--footer_form elements: ${footerForms.length}`);
  7.  
  8. footerForms.each(function(index) {
  9. var $form = $(this);
  10.  
  11. console.log(`Processing footer form ${index + 1}...`);
  12. new Waypoint({
  13. element: $form[0],
  14. handler: function() {
  15. const titleElements = $form[0].querySelectorAll('.title');
  16. const actionElements = $form[0].querySelectorAll('.actions');
  17.  
  18. console.log(`Footer Form ${index + 1}: Found ${titleElements.length} title elements.`);
  19. console.log(`Footer Form ${index + 1}: Found ${actionElements.length} action elements.`);
  20.  
  21. // Animate title elements
  22. anime({
  23. targets: titleElements,
  24. translateY: [100, 0],
  25. opacity: [0, 1],
  26. easing: 'easeOutQuad',
  27. delay: anime.stagger(100)
  28. });
  29.  
  30. // Animate action elements
  31. if (actionElements.length) {
  32. anime({
  33. targets: actionElements,
  34. opacity: [0, 1],
  35. easing: 'easeOutQuad'
  36. });
  37. }
  38.  
  39. this.destroy(); // Destroy waypoint after triggering
  40. },
  41. offset: '90%',
  42. });
  43. });
  44. }
  45.  
  46.  
  47. // Additional Module Animations
  48. function initializeAnimations() {
  49. const animations = [
  50. { selector: '.module--subindustry', targets: '.image-container img, .image-container .video-popup, .fade-in', offset: '100%' },
  51. { selector: '.module--masthead-v2', targets: '.image-container img, .image-container .video-popup, .fade-in', offset: '100%' },
  52. ];
  53.  
  54. animations.forEach(({ selector, targets, offset, translateX }) => {
  55. $(selector).each(function() {
  56. const $self = $(this);
  57. $self.waypoint({
  58. handler: function() {
  59. const animationSettings = {
  60. targets: $self[0].querySelectorAll(targets),
  61. translateY: [100, 0],
  62. opacity: [0, 1],
  63. easing: 'easeOutQuad',
  64. delay: anime.stagger(100)
  65. };
  66.  
  67. if (translateX) animationSettings.translateX = translateX;
  68.  
  69. anime(animationSettings);
  70. this.destroy();
  71. },
  72. offset
  73. });
  74. });
  75. });
  76. }
  77.  
  78. // Sub Industry
  79. function initializeTabber() {
  80.  
  81. // Initialize Variables
  82. var timing = 200,
  83. tabs = document.querySelectorAll('.module--subindustry [role="tab"]'),
  84. panels = document.querySelectorAll('.module--subindustry [role="slidepanel"]'),
  85. underline = document.querySelector('.module--subindustry .button-underline');
  86.  
  87. // Initialize Nav Tabs
  88. tabs.forEach((tab, index) => {
  89. tab.index = index;
  90. tab.addEventListener('click', () => activateTab(tab));
  91. });
  92.  
  93. // Initialize Panels
  94. panels.forEach(panel => panel.setAttribute('hidden', 'true'));
  95.  
  96. // Activate the first tab or the one matching the URL hash
  97. initialTab = tabs[0];
  98. hashTab = document.getElementById(window.location.hash.substr(1));
  99. if (hashTab && hashTab.getAttribute('role') === 'tab') {
  100. activateTab(hashTab);
  101. } else {
  102. activateTab(initialTab);
  103. }
  104.  
  105. // Event Functions
  106. function activateTab(tab, setFocus = false) {
  107. targetPanelId = tab.getAttribute('aria-controls');
  108. deactivateTabs();
  109. tab.removeAttribute('tabindex');
  110. tab.setAttribute('aria-selected', 'true');
  111.  
  112. if (underline) {
  113. underline.style.left = `${tab.offsetLeft}px`;
  114. underline.style.width = `${tab.offsetWidth}px`;
  115. }
  116.  
  117. activePanel = document.getElementById(targetPanelId);
  118. activePanel.removeAttribute('hidden');
  119. setTimeout(() => activePanel.classList.add('active'), timing);
  120. }
  121.  
  122. // // Deactivate all tabs and tab panels
  123. function deactivateTabs( ignore ) {
  124. tabs.forEach((tab, i) => {
  125. tab.setAttribute('tabindex', '-1');
  126. tab.setAttribute('aria-selected', 'false');
  127. });
  128.  
  129. panels.forEach((panel, i) => {
  130. if( panel.getAttribute( 'id' ) !== ignore && panel.classList.contains( 'active' ) ){
  131. panel.classList.remove( 'active' );
  132. panel.classList.add( 'transition' );
  133. setTimeout( function(){
  134. panel.setAttribute( 'hidden', 'hidden' );
  135. panel.classList.remove( 'transition' );
  136. }, timing );
  137. }
  138. });
  139. };
  140.  
  141. }
  142.  
  143. $(document).ready(function(){
  144. initializeAnimations();
  145.  
  146. setTimeout(function(){
  147.  
  148. // Remove all existing waypoints related to .module--footer_form
  149. $('.module--footer_form').each(function () {
  150. var $this = $(this);
  151. $.each(Waypoint.instances, function (i, waypoint) {
  152. if (waypoint.element === $this[0]) {
  153. waypoint.destroy();
  154. }
  155. });
  156. });
  157.  
  158. }, 1000);
  159.  
  160. setTimeout(function(){
  161. initializeAnims();
  162. }, 2000);
  163. });
  164.  
  165. // Load Tabber if it exists
  166. if($('.module--subindustry').length) {
  167. window.addEventListener('load', initializeTabber);
  168. }
  169.  
  170. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement