Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- function initializeAnims() {
- const footerForms = $('.module--footer_form');
- console.log(`Total .module--footer_form elements: ${footerForms.length}`);
- footerForms.each(function(index) {
- var $form = $(this);
- console.log(`Processing footer form ${index + 1}...`);
- new Waypoint({
- element: $form[0],
- handler: function() {
- const titleElements = $form[0].querySelectorAll('.title');
- const actionElements = $form[0].querySelectorAll('.actions');
- console.log(`Footer Form ${index + 1}: Found ${titleElements.length} title elements.`);
- console.log(`Footer Form ${index + 1}: Found ${actionElements.length} action elements.`);
- // Animate title elements
- anime({
- targets: titleElements,
- translateY: [100, 0],
- opacity: [0, 1],
- easing: 'easeOutQuad',
- delay: anime.stagger(100)
- });
- // Animate action elements
- if (actionElements.length) {
- anime({
- targets: actionElements,
- opacity: [0, 1],
- easing: 'easeOutQuad'
- });
- }
- this.destroy(); // Destroy waypoint after triggering
- },
- offset: '90%',
- });
- });
- }
- // Additional Module Animations
- function initializeAnimations() {
- const animations = [
- { selector: '.module--subindustry', targets: '.image-container img, .image-container .video-popup, .fade-in', offset: '100%' },
- { selector: '.module--masthead-v2', targets: '.image-container img, .image-container .video-popup, .fade-in', offset: '100%' },
- ];
- animations.forEach(({ selector, targets, offset, translateX }) => {
- $(selector).each(function() {
- const $self = $(this);
- $self.waypoint({
- handler: function() {
- const animationSettings = {
- targets: $self[0].querySelectorAll(targets),
- translateY: [100, 0],
- opacity: [0, 1],
- easing: 'easeOutQuad',
- delay: anime.stagger(100)
- };
- if (translateX) animationSettings.translateX = translateX;
- anime(animationSettings);
- this.destroy();
- },
- offset
- });
- });
- });
- }
- // Sub Industry
- function initializeTabber() {
- // Initialize Variables
- var timing = 200,
- tabs = document.querySelectorAll('.module--subindustry [role="tab"]'),
- panels = document.querySelectorAll('.module--subindustry [role="slidepanel"]'),
- underline = document.querySelector('.module--subindustry .button-underline');
- // Initialize Nav Tabs
- tabs.forEach((tab, index) => {
- tab.index = index;
- tab.addEventListener('click', () => activateTab(tab));
- });
- // Initialize Panels
- panels.forEach(panel => panel.setAttribute('hidden', 'true'));
- // Activate the first tab or the one matching the URL hash
- initialTab = tabs[0];
- hashTab = document.getElementById(window.location.hash.substr(1));
- if (hashTab && hashTab.getAttribute('role') === 'tab') {
- activateTab(hashTab);
- } else {
- activateTab(initialTab);
- }
- // Event Functions
- function activateTab(tab, setFocus = false) {
- targetPanelId = tab.getAttribute('aria-controls');
- deactivateTabs();
- tab.removeAttribute('tabindex');
- tab.setAttribute('aria-selected', 'true');
- if (underline) {
- underline.style.left = `${tab.offsetLeft}px`;
- underline.style.width = `${tab.offsetWidth}px`;
- }
- activePanel = document.getElementById(targetPanelId);
- activePanel.removeAttribute('hidden');
- setTimeout(() => activePanel.classList.add('active'), timing);
- }
- // // Deactivate all tabs and tab panels
- function deactivateTabs( ignore ) {
- tabs.forEach((tab, i) => {
- tab.setAttribute('tabindex', '-1');
- tab.setAttribute('aria-selected', 'false');
- });
- panels.forEach((panel, i) => {
- if( panel.getAttribute( 'id' ) !== ignore && panel.classList.contains( 'active' ) ){
- panel.classList.remove( 'active' );
- panel.classList.add( 'transition' );
- setTimeout( function(){
- panel.setAttribute( 'hidden', 'hidden' );
- panel.classList.remove( 'transition' );
- }, timing );
- }
- });
- };
- }
- $(document).ready(function(){
- initializeAnimations();
- setTimeout(function(){
- // Remove all existing waypoints related to .module--footer_form
- $('.module--footer_form').each(function () {
- var $this = $(this);
- $.each(Waypoint.instances, function (i, waypoint) {
- if (waypoint.element === $this[0]) {
- waypoint.destroy();
- }
- });
- });
- }, 1000);
- setTimeout(function(){
- initializeAnims();
- }, 2000);
- });
- // Load Tabber if it exists
- if($('.module--subindustry').length) {
- window.addEventListener('load', initializeTabber);
- }
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement