window.onbeforeunload = function () { window.scrollTo(0, 0); }; // CODE ALL /////////////////////////////////////////////////////////////////////////////////////// function initializeAll() { const menuButton = document.querySelector('.nav_menu-button'); const body = document.body; let isMenuOpen = false; // Toggle menu state on menu button click menuButton.addEventListener('click', function () { isMenuOpen = !isMenuOpen; if (isMenuOpen) { body.classList.add('overflow-hidden'); } else { body.classList.remove('overflow-hidden'); } }); document.addEventListener('click', function (event) { if ( event.target.matches('.nav_menu-inner-link') || event.target.matches('.nav_menu-button-over') || event.target.matches('.nav_overlay') ) { isMenuOpen = false; body.classList.remove('overflow-hidden'); } }); const allStudiesLink = document.querySelectorAll('.study-link'); allStudiesLink.forEach(link => { const allStudiesButton = link.querySelector('.button.is-arrow.is-study'); // Add event listeners if button exists within the link if (allStudiesButton) { link.addEventListener('mouseenter', function () { allStudiesButton.classList.add('hover'); }); link.addEventListener('mouseleave', function () { allStudiesButton.classList.remove('hover'); }); } }); const allEventsLink = document.querySelectorAll('.events_link'); allEventsLink.forEach(link => { const allEventsButton = link.querySelector('.button.is-arrow.is-event'); // Add event listeners if button exists within the link if (allEventsButton) { link.addEventListener('mouseenter', function () { allEventsButton.classList.add('hover'); }); link.addEventListener('mouseleave', function () { allEventsButton.classList.remove('hover'); }); } }); } // CODE HOME /////////////////////////////////////////////////////////////////////////////////////// function initializeHome() { gsap.from('.is-hero', { opacity: 0, duration: 1, delay: 0.25, ease: 'power2.inOut', }); gsap.from('.is-subtitle', { opacity: 0, duration: 1, delay: 3.75, ease: 'power2.inOut', }); let startSplit = new SplitType('.is-start', { types: 'chars', tagName: 'span' }); let typeSplit = new SplitType('.is-making-it', { types: 'lines, words, chars', tagName: 'span' }); gsap.from('.is-start .char', { opacity: 0, duration: 0.65, delay: 2, ease: 'power2.inOut', stagger: 0.15, }); gsap.from('.is-making-it .char', { y: '120%', duration: 1.5, delay: 2.5, ease: 'expo.inOut', stagger: 0.05, }); const homeSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.home-studies_wrapper', { wrapperClass: 'home-studies_list', slideClass: 'home-studies_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 2.5, }, 992: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, noSwipingClass: 'study-link', a11y: false, slidesPerView: 4, }, 1440: { spaceBetween: homeSliderSpacer, grabCursor: false, allowTouchMove: false, simulateTouch: false, noSwipingClass: 'study-link', a11y: false, slidesPerView: 4, } } }); const swiperWrapper = document.querySelector(".testimonials_wrapper"); const lastSwiperSlide = document.querySelector(".testimonials_item:last-of-type"); var swiper = new Swiper('.testimonials_swiper', { wrapperClass: 'testimonials_wrapper', slideClass: 'testimonials_item', spaceBetween: 16, grabCursor: true, a11y: false, slidesPerView: 1.05, autoplay: { delay: 5000, }, loop: true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, breakpoints: { 992: { spaceBetween: 96, grabCursor: true, a11y: false, observer: true, observeParents: true, slidesPerView: 'auto', slidesOffsetAfter: 0, } }, on: { slideChange: function () { const nextButton = document.querySelector('.swiper-button-next'); if (window.innerWidth >= 992) { // Check if screen width is 992px or above if (this.activeIndex === this.slides.length - 2) { this.allowSlideNext = false; // Prevent swiping to the last slide nextButton.classList.add('swiper-button-disabled'); // Disable the Next button } else { this.allowSlideNext = true; // Allow swiping otherwise nextButton.classList.remove('swiper-button-disabled'); // Enable the Next button } } else { // Always allow swiping on smaller screens this.allowSlideNext = true; nextButton.classList.remove('swiper-button-disabled'); } }, }, }); $('[data-click="accordion"]').click(function () { if (!$(this).is('.open')) { $('[data-click="accordion"].open').each((i, item) => { item.click(); }); $(this).addClass('open'); } else { $(this).removeClass('open'); } }); function handleButtonTextVisibility() { const buttonTextMobileElements = document.querySelectorAll('.button-text-mobile'); buttonTextMobileElements.forEach(function (mobileTextElement) { const siblingTextElement = mobileTextElement.parentElement.querySelector( '.button-text'); if (window.innerWidth < 479) { // If the viewport is smaller than 479px, show the .button-text-mobile mobileTextElement.style.display = 'block'; // If the sibling .button-text exists, hide it if (siblingTextElement) { siblingTextElement.style.display = 'none'; } } else { // If the viewport is 479px or larger, hide the .button-text-mobile mobileTextElement.style.display = 'none'; // If the sibling .button-text exists, show it if (siblingTextElement) { siblingTextElement.style.display = 'block'; } } }); } handleButtonTextVisibility(); const navBrands = document.querySelectorAll('.nav_brand, .nav_menu-link'); navBrands.forEach(navBrand => { navBrand.addEventListener('click', function (event) { const linkHref = new URL(navBrand.href).pathname; const currentPath = window.location.pathname; if (currentPath === linkHref) { // Prevent default only if it's the current page event.preventDefault(); // Ensure smooth scroll to top window.scrollTo({ top: 0, behavior: 'smooth' }); } }); }); $(".plyr_component").each(function (index) { let thisComponent = $(this); let player = new Plyr(thisComponent.find(".plyr_video")[0], { controls: ["play", "mute"], resetOnEnd: true, hideControls: true, muted: true, autoplay: true, }); player.on("play", (event) => { $(".plyr_cover").addClass("hide-cover"); let prevPlayingComponent = $(".plyr--playing").closest(".plyr_component").not( thisComponent); if (prevPlayingComponent.length > 0) { prevPlayingComponent.find(".plyr_pause-trigger")[0].click(); } }); thisComponent.find(".plyr_pause-trigger").on("click", function () { player.pause(); }); player.on("ended", (event) => { if (player.fullscreen.active) { player.fullscreen.exit(); } }); player.on("enterfullscreen", (event) => { thisComponent.addClass("contain-video"); }); player.on("exitfullscreen", (event) => { thisComponent.removeClass("contain-video"); }); }); const logosWrapper = document.querySelector('.home-logos_list-wrapper'); if (logosWrapper) { const wrapperWidth = logosWrapper.offsetWidth; logosWrapper.style.width = `${wrapperWidth}px`; } function splideLogos() { const logosSliderSpacer = window.innerWidth * 0.015; var splideLogos = new Splide('.home-logos_wrapper', { type: 'loop', perPage: 'auto', focus: 'center', gap: '64px', autoWidth: true, autoScroll: { speed: 1, }, arrows: false, pagination: false, height: "auto", drag: "free", breakpoints: { 1440: { gap: '64px', }, 991: { gap: '48px', }, 767: { gap: '48px', }, 479: { gap: '40px', }, }, }); splideLogos.mount(window.splide.Extensions); const logosSliderElement = document.querySelector('.home-logos_wrapper'); logosSliderElement.addEventListener('mouseenter', () => splideLogos.Components.Autoplay .pause()); logosSliderElement.addEventListener('mouseleave', () => splideLogos.Components.Autoplay .play()); } if (window.location.pathname === '/') { splideLogos(); } } /////////////////////////////////////////////////////////////////////////////////////// // CODE STUDIES function initializeStudies() { var swiper = new Swiper('.studies-hero_wrapper', { wrapperClass: 'studies-hero_list', slideClass: 'studies-hero_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.1, } } }); function updateLabelVisibility() { const radioButton = document.getElementById('radio-all'); const labelBlack = document.getElementById('radio-all-black'); const labelWhite = document.getElementById('radio-all-white'); if (radioButton && labelBlack && labelWhite) { if (radioButton.checked) { labelBlack.style.display = 'block'; labelWhite.style.display = 'none'; } else { labelBlack.style.display = 'none'; labelWhite.style.display = 'block'; } } } function handleFilterItems() { const labelBlack = document.getElementById('radio-all-black'); const labelWhite = document.getElementById('radio-all-white'); if (labelBlack && labelWhite) { labelBlack.style.display = 'none'; labelWhite.style.display = 'block'; } } updateLabelVisibility(); const radioButton = document.getElementById('radio-all'); if (radioButton) { radioButton.addEventListener('change', updateLabelVisibility); radioButton.addEventListener('focusout', updateLabelVisibility); } // Add event listeners for filter items const filterItems = document.querySelectorAll('.filters-item.w-dyn-item'); filterItems.forEach(item => { item.addEventListener('click', handleFilterItems); }); }; /////////////////////////////////////////////////////////////////////////////////////// // CODE SERVICES function initializeServices() { const servicesDiffSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.services-diff_wrapper', { wrapperClass: 'services-diff_list', slideClass: 'services-diff_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, }, 992: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, }, 1440: { spaceBetween: servicesDiffSliderSpacer, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, } } }); function splideOne() { const awardsSliderSpacer = window.innerWidth * 0.015; var splideAwards = new Splide('.services-awards_wrapper', { type: 'loop', perPage: 'auto', focus: 'center', gap: '24px', autoWidth: true, autoScroll: { speed: 1, }, arrows: false, pagination: false, height: "auto", drag: "free", breakpoints: { 1440: { gap: `${awardsSliderSpacer}px`, }, }, }); splideAwards.mount(window.splide.Extensions); const awardsSliderElement = document.querySelector('.services-awards_wrapper'); awardsSliderElement.addEventListener('mouseenter', () => splideAwards.Components.Autoplay .pause()); awardsSliderElement.addEventListener('mouseleave', () => splideAwards.Components.Autoplay .play()); } if (window.location.pathname === '/services') { splideOne(); } gsap.registerPlugin(ScrollTrigger); ScrollTrigger.defaults({ markers: false }); const animations = [ { selector: ".service-images_image-1", yValue: "-60%" }, { selector: ".service-images_image-2", yValue: "-282px" }, { selector: ".service-images_image-3", yValue: "-192px" }, { selector: ".service-images_image-4", yValue: "-256px" } ]; animations.forEach(({ selector, yValue }) => { $(selector).each(function () { gsap.timeline({ scrollTrigger: { trigger: $(".section_services-images"), start: "top 100%", end: "bottom top", scrub: 2, } }).from($(this), { y: yValue }); }); }); }; /////////////////////////////////////////////////////////////////////////////////////// // CODE ABOUT function initializeAbout() { const aboutTeamSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.about-team_wrapper', { wrapperClass: 'about-team_list', slideClass: 'about-team_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 2.5, }, 992: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 4, }, 1440: { spaceBetween: aboutTeamSliderSpacer, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 4, } } }); function splideThree() { const valuesSliderSpacer = window.innerWidth * 0.015; var splideValues = new Splide('.about-values_wrapper', { type: 'loop', perPage: 'auto', focus: 'center', gap: '24px', autoWidth: true, autoScroll: { speed: 1, }, arrows: false, pagination: false, height: "auto", drag: "free", breakpoints: { 1440: { gap: `${valuesSliderSpacer}px`, }, 991: { gap: '24px', perPage: 2.5, }, 767: { gap: '20px', perPage: 1.4, autoScroll: false, focus: 'left', padding: { left: '20px' }, snap: true, }, 479: { gap: '16px', perPage: 1.1, padding: { left: '16px' } }, }, }); } const aboutCultureSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.section_about-culture', { wrapperClass: 'about-culture_list', slideClass: 'about-culture_item', loop: true, centeredSlides: true, spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, autoplay: { delay: 3000, }, breakpoints: { 479: { spaceBetween: 20, slidesPerView: 1.4, }, 768: { spaceBetween: 24, slidesPerView: 2.5, }, 992: { spaceBetween: 24, slidesPerView: 4, }, 1440: { spaceBetween: aboutCultureSliderSpacer, slidesPerView: 4, } } }); }; ///////// // CODE INSIGHTS function initializeInsights() { const insightsLink = document.querySelectorAll('.insights_link'); insightsLink.forEach(link => { const insightsButton = link.querySelector('.button.is-arrow'); if (insightsButton) { link.addEventListener('mouseenter', function () { insightsButton.classList.add('hover'); }); link.addEventListener('mouseleave', function () { insightsButton.classList.remove('hover'); }); } }); } /////////////////////////////////////////////////////////////////////////////////////// // CODE EVENTS function initializeEvents() { $('[data-click="accordion-events"]').click(function () { if (!$(this).is('.open')) { $('[data-click="accordion-events"].open').each((i, item) => { item.click(); }); $(this).addClass('open'); } else { $(this).removeClass('open'); } }); const eventsTalksSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.event-talks_wrapper', { wrapperClass: 'event-talks_list', slideClass: 'event-talks_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 2.5, }, 992: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, }, 1440: { spaceBetween: eventsTalksSliderSpacer, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, } } }); const eventsTakeawaysSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.event-takeaways_wrapper', { wrapperClass: 'event-takeaways_list', slideClass: 'event-takeaways_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 2.5, }, 992: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, }, 1440: { spaceBetween: eventsTakeawaysSliderSpacer, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 3, } } }); }; /////////////////////////////////////////////////////////////////////////////////////// // CODE CONTACT function initializeContact() { ScrollTrigger.defaults({ markers: false }); const animations = [ { selector: ".contact-hero_image-1", yValue: "-60%" }, { selector: ".contact-hero_image-2", yValue: "-282px" }, { selector: ".contact-hero_image-3", yValue: "-192px" }, { selector: ".contact-hero_image-4", yValue: "-256px" } ]; animations.forEach(({ selector, yValue }) => { $(selector).each(function () { gsap.timeline({ scrollTrigger: { trigger: $(".section_contact-hero"), start: "top top", end: "bottom top", scrub: 2, } }).from($(this), { y: yValue }); }); }); var swiper = new Swiper('.contact-images_wrapper', { wrapperClass: 'contact-images_grid', slideClass: 'contact-images_image', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, a11y: false, slidesPerView: 'auto' } } }); const forms = document.querySelectorAll('form[ms-code-submit-form]'); forms.forEach(form => { const submitButton = form.querySelector('input[type="submit"]'); const requiredFields = form.querySelectorAll( 'input[required], textarea[required], input[type="checkbox"][required]'); form.addEventListener('input', function () { const allFilled = Array.from(requiredFields).every(field => { if (field.type === 'checkbox') { // Ensure the checkbox is checked return field.checked; } else { return field.value.trim() !== ''; } }); if (allFilled) { submitButton.classList.add('submit-enabled'); } else { submitButton.classList.remove('submit-enabled'); } }); }); }; // CODE SINGLE PAST EVENT /////////////////////////////////////////////////////////////////////////////////////// function initializePastEvent() { const players = new Map(); const showVideoConsent = localStorage.getItem('showVideos'); // Alternatively, you can bind showVideoConsent to your preferred cookie consent. const placeholders = document.querySelectorAll('[video-component="placeholder"]'); const videoContainers = Array.from(document.querySelectorAll('[video-component="container"]')); // Initialize Plyr for components without a placeholder videoContainers.forEach(function (container, index) { const placeholder = container.querySelector('[video-component="placeholder"]'); if (!placeholder) { loadVideo(container, players, index); } }); if (showVideoConsent) { loadAllVideos(videoContainers, players); hideAllPlaceholders(placeholders); } else { document.querySelectorAll('[video-component="load-video"]').forEach(function (button) { // Load Videos with click on Play Buttons button.addEventListener('click', function () { // Here you can add a snippet of your cookie consent to update the user's cookie preferences. localStorage.setItem('showVideos', true); loadAllVideos(videoContainers, players); placeholders.forEach((placeholder) => { placeholder.style.position = 'absolute'; }); hideAllPlaceholders(placeholders); const videoContainer = button.closest('[video-component="container"]'); const index = videoContainers.indexOf(videoContainer); playVideo(players, index); }); // Load Videos with "Enter" on Play Buttons button.addEventListener('keydown', function (event) { if (event.key === 'Enter') { // Here you can add a snippet of your cookie consent to update the user's cookie preferences. localStorage.setItem('showVideos', true); loadAllVideos(videoContainers, players); placeholders.forEach((placeholder) => { placeholder.style.position = 'absolute'; }); hideAllPlaceholders(placeholders); const videoContainer = button.closest('[video-component="container"]'); const index = videoContainers.indexOf(videoContainer); playVideo(players, index); } }); }); } function loadAllVideos(videoContainers, players) { // Create a Plyr player for each video container videoContainers.forEach(function (container, index) { loadVideo(container, players, index); }); } function loadVideo(videoContainer, players, index) { const videoPlayer = videoContainer.querySelector('[video-component="player"]'); // Check if videoPlayer exists and has a data-plyr-provider attribute if (videoPlayer && videoPlayer.hasAttribute('data-plyr-provider')) { const provider = videoPlayer.getAttribute('data-plyr-provider'); const embedId = videoPlayer.getAttribute('data-plyr-embed-id'); // Create Plyr player // Customise the controls for your video elements if you wish. // Check out the Plyr documentation at github.com/sampotts/plyr const player = new Plyr(videoPlayer, { controls: ['play-large', 'play', 'progress', 'current-time', 'volume', 'fullscreen'], settings: ['captions', 'quality'], youtube: { noCookie: true, rel: 0, showinfo: 0, iv_load_policy: 3, modestbranding: 1, autoplay: 0, playsinline: 0, controls: 0, }, }); // Load video from provider player.source = { type: 'video', sources: [ { src: embedId, provider: provider, }, ], }; // Store player instance in the map players.set(index, player); } // If videoPlayer exists, but doesn't have a data-plyr-provider attribute else if (videoPlayer) { const player = new Plyr(videoPlayer, { controls: ['play-large', 'play', 'progress', 'current-time', 'volume', 'fullscreen'], settings: ['captions', 'quality'], }); // Store player instance in the map players.set(index, player); } } function playVideo(players, index) { const player = players.get(index); player.on('ready', function () { player.play(); }); } function hideAllPlaceholders(placeholders) { // Hide all placeholders placeholders.forEach(function (placeholder) { placeholder.style.display = 'none'; }); } const pageTitle = document.title; // Set the value of the hidden input const hiddenInput = document.getElementById('page-title-input'); if (hiddenInput) { hiddenInput.value = pageTitle; } } // CODE SINGLE INSIGHT /////////////////////////////////////////////////////////////////////////////////////// function initializeInsight() { const insightSliderSpacer = window.innerWidth * 0.015; var swiper = new Swiper('.insight-more_wrapper', { wrapperClass: 'insight-more_list', slideClass: 'insight-more_item', spaceBetween: 16, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.05, breakpoints: { 479: { spaceBetween: 20, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 1.4, }, 768: { spaceBetween: 24, grabCursor: true, allowTouchMove: true, simulateTouch: true, a11y: false, slidesPerView: 2.5, }, 992: { spaceBetween: 24, grabCursor: false, allowTouchMove: false, simulateTouch: false, noSwipingClass: 'insight-link', a11y: false, slidesPerView: 4, }, 1440: { spaceBetween: insightSliderSpacer, grabCursor: false, allowTouchMove: false, simulateTouch: false, noSwipingClass: 'insight-link', a11y: false, slidesPerView: 4, } } }); const insightsLink = document.querySelectorAll('.insight-more_item'); insightsLink.forEach(link => { const insightsButton = link.querySelector('.button.is-arrow.is-insight'); if (insightsButton) { link.addEventListener('mouseenter', function () { insightsButton.classList.add('hover'); }); link.addEventListener('mouseleave', function () { insightsButton.classList.remove('hover'); }); } }); } /////////////////////////////////////////////////////////////////////////////////////// // GSAP ANIMATION function gsapAnimations() { const previousURL = localStorage.getItem('previousURL'); const currentURL = window.location.href; const isSamePageReload = previousURL === currentURL; localStorage.setItem('previousURL', currentURL); gsap.from('.main-wrapper > *', { opacity: 0, y: isSamePageReload ? 0 : 24, duration: isSamePageReload ? 1.5 : 0.65, delay: 0.25, ease: "power2.out", autoAlpha: 0 }); const currentPath = window.location.pathname; if (document.querySelector('.section_past-hero')) { // Ensure the nav starts transparent gsap.set(".nav_component", { backgroundColor: "rgba(0, 0, 0, 0)", }); // Animate to the resolved theme background color gsap.to(".nav_component", { backgroundColor: "black", ease: "none", scrollTrigger: { trigger: ".page-wrapper", start: "120px top", end: "+=144px", scrub: 1, }, }); } else { gsap.set(".nav_component", { backgroundColor: "var(--_themes---nav--background)", }); } } /////////////////////////////////////////////////////////////////////////////////////// // Function to initialize color themes and scroll animations function initColorThemes() { const colorThemes = []; const htmlStyles = getComputedStyle(document.documentElement); const targetStylesheet = document.querySelector("#color-themes"); const regex = /--([^:\s]+):\s*var\(--([^)]+)\);/g; if (targetStylesheet) { const rules = targetStylesheet.sheet.cssRules || targetStylesheet.sheet.rules; for (const rule of rules) { const styleObject = {}; let match; while ((match = regex.exec(rule.cssText)) !== null) { const key = "--" + match[1]; const value = htmlStyles.getPropertyValue("--" + match[2]); styleObject[key] = value; } colorThemes.push(styleObject); } // Kill any existing ScrollTriggers to prevent duplicates ScrollTrigger.getAll().forEach((trigger) => trigger.kill()); const triggerElements = document.querySelectorAll("[animate-body-to]"); triggerElements.forEach((element, index) => { const modeIndex = +element.getAttribute("animate-body-to"); gsap.matchMedia().add(`(min-width: 0px)`, () => { const colorScroll = gsap.timeline({ scrollTrigger: { trigger: element, start: "top center", end: "bottom center", toggleActions: "play complete none reverse", }, }); colorScroll.to("body", { ...colorThemes[modeIndex - 1], duration: 0.4, ease: "power1.out", }); }); }); } } // Initialize Barba.js with custom transitions barba.init({ transitions: [ { name: "opacity", async leave(data) { await gsap.to(data.current.container, { opacity: 0, duration: 0.25 }); }, async beforeEnter(data) { window.scrollTo(0, 0); }, async enter(data) { await gsap.to(data.next.container, { opacity: 1, duration: 0.25 }); }, }, ], }); document.addEventListener("DOMContentLoaded", () => { initColorThemes(); initializeAll(); initializeHome(); initializeStudies(); initializeServices(); initializeAbout(); initializeInsights(); initializeEvents(); initializeContact(); initializePastEvent(); initializeInsight(); gsapAnimations(); }); barba.hooks.after((data) => { Webflow.destroy(); Webflow.ready(); Webflow.require('ix2')?.init(); initColorThemes(); initializeAll(); initializeHome(); initializeStudies(); initializeAbout(); initializeServices(); initializeInsights(); initializeEvents(); initializeContact(); initializePastEvent(); initializeInsight(); gsapAnimations(); window.fsAttributes.destroy(); window.fsAttributes.cmsfilter.init(); window.fsAttributes.cmsstatic.init(); window.fsAttributes.autovideo.init(); window.fsAttributes.socialshare.init(); });