document.addEventListener('DOMContentLoaded', function() { // Initialize slide navigation initializeSlideNavigation(); // Initialize scroll animations initializeScrollAnimations(); // Initialize metrics counter (simulated) initializeMetrics(); // Smooth scroll for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Initialize tooltips for icons initializeTooltips(); }); function initializeSlideNavigation() { const slideNav = document.getElementById('slide-nav'); const slideContents = document.querySelectorAll('.slide-content'); if (!slideNav || slideContents.length === 0) return; // Create navigation items for each slide const slideTitles = [ "Cover ✨", "The Problem 🔴", "Market Shift 📈", "The Solution 💡", "Product Walkthrough 🚀", "Funnel Comparison 📊", "Traction 📈", "Business Model 💰", "Acquisition Value 🎯", "Competitive Position ⚔️", "Integration Path 🔧", "Exit Intent 🎪" ]; slideNav.innerHTML = slideTitles.map((title, index) => ` `).join(''); // Add click handlers document.querySelectorAll('.slide-nav-item').forEach(button => { button.addEventListener('click', function() { const targetSlide = this.getAttribute('data-target'); // Update active state document.querySelectorAll('.slide-nav-item').forEach(btn => { btn.classList.remove('active'); }); this.classList.add('active'); // Scroll to slide const slideElement = document.querySelector(`[data-slide="${targetSlide}"]`); if (slideElement) { slideElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); } function initializeScrollAnimations() { const observerOptions = { root: null, rootMargin: '0px', threshold: 0.1 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-in'); } }); }, observerOptions); // Observe all slide contents document.querySelectorAll('.slide-content').forEach(slide => { observer.observe(slide); }); } function initializeMetrics() { // Simulate live metrics update const metrics = { activationRate: 42, scanToSignup: 28, signupToPaid: 65, retention: 92 }; // Animate metrics on scroll const metricsObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { animateValue('activation-rate', 0, metrics.activationRate, 1500); animateValue('scan-to-signup', 0, metrics.scanToSignup, 1500); animateValue('signup-to-paid', 0, metrics.signupToPaid, 1500); animateValue('retention', 0, metrics.retention, 1500); metricsObserver.unobserve(entry.target); } }); }, { threshold: 0.5 }); const metricsSection = document.getElementById('traction-metrics'); if (metricsSection) { metricsObserver.observe(metricsSection); } } function animateValue(id, start, end, duration) { const element = document.getElementById(id); if (!element) return; let startTimestamp = null; const step = (timestamp) => { if (!startTimestamp) startTimestamp = timestamp; const progress = Math.min((timestamp - startTimestamp) / duration, 1); const value = Math.floor(progress * (end - start) + start); element.textContent = value + '%'; if (progress < 1) { window.requestAnimationFrame(step); } }; window.requestAnimationFrame(step); } function initializeTooltips() { // Initialize tooltips for icons with data-tooltip attribute document.querySelectorAll('[data-tooltip]').forEach(element => { element.addEventListener('mouseenter', function(e) { const tooltip = document.createElement('div'); tooltip.className = 'fixed z-50 px-3 py-2 bg-gray-900 text-white text-sm rounded-lg shadow-lg'; tooltip.textContent = this.getAttribute('data-tooltip'); tooltip.style.left = e.pageX + 'px'; tooltip.style.top = (e.pageY - 40) + 'px'; tooltip.id = 'dynamic-tooltip'; document.body.appendChild(tooltip); }); element.addEventListener('mouseleave', function() { const tooltip = document.getElementById('dynamic-tooltip'); if (tooltip) { tooltip.remove(); } }); element.addEventListener('mousemove', function(e) { const tooltip = document.getElementById('dynamic-tooltip'); if (tooltip) { tooltip.style.left = e.pageX + 'px'; tooltip.style.top = (e.pageY - 40) + 'px'; } }); }); } // API Integration - Simulated data fetch for pitch deck content async function fetchTractionData() { try { // In production, this would fetch from your API const response = await fetch('https://api.mockapi.io/traction', { method: 'GET', headers: { 'Content-Type': 'application/json' } }); if (!response.ok) { throw new Error('Failed to fetch traction data'); } const data = await response.json(); updateTractionDisplay(data); } catch (error) { console.log('Using simulated traction data'); // Fallback to simulated data const simulatedData = { activationRate: 42, scanToSignup: 28, signupToPaid: 65, retention: 92, arpu: 14.5, mrr: 85000 }; updateTractionDisplay(simulatedData); } } function updateTractionDisplay(data) { // Update traction metrics in the UI console.log('Traction data updated:', data); } // Export functions for web components if needed window.AppUtils = { initializeSlideNavigation, animateValue, fetchTractionData };