(function () { // 1) Stop future theme changes from doing anything function noopThemeGetter() { return {}; } if (window.colorThemes) window.colorThemes.getTheme = noopThemeGetter; document.addEventListener('colorThemesReady', function () { if (window.colorThemes) window.colorThemes.getTheme = noopThemeGetter; }); // 2) Remove data attributes so no ScrollTriggers will be created for them function stripThemeAttrs() { document.querySelectorAll('[data-animate-theme-to]').forEach(el => { el.removeAttribute('data-animate-theme-to'); el.removeAttribute('data-animate-brand-to'); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', stripThemeAttrs); } else { stripThemeAttrs(); } // 3) If anything already registered, kill those ScrollTriggers function killExistingThemeTriggers() { if (!window.ScrollTrigger) return; ScrollTrigger.getAll().forEach(t => { const trg = t.vars && t.vars.trigger; const el = trg && (trg.jquery ? trg[0] : trg); if (el && el.matches && el.matches('[data-animate-theme-to]')) t.kill(); }); } // Run now and again after colorThemesReady (in case it initialized earlier) if (document.readyState !== 'loading') killExistingThemeTriggers(); document.addEventListener('colorThemesReady', killExistingThemeTriggers); // 4) Clean any inline body styles previously applied by GSAP function cleanBodyInline() { const s = document.body && document.body.style; if (!s) return; s.removeProperty('background-color'); s.removeProperty('color'); // Remove any inline CSS variables like --_theme-* const css = document.body.getAttribute('style') || ''; if (css.includes('--_theme')) { document.body.setAttribute( 'style', css.replace(/--_theme[\w-]+\s*:\s*[^;]+;?/g, '') ); } } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', cleanBodyInline); } else { cleanBodyInline(); } })();