Spaces:
Running
Running
File size: 7,436 Bytes
099b283 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | 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) => `
<button class="slide-nav-item w-full text-left p-3 rounded-lg mb-2 hover:bg-indigo-50 transition-colors ${index === 0 ? 'active' : ''}"
data-target="${index + 1}">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
<span class="text-indigo-700 font-bold">${index + 1}</span>
</div>
<span class="font-medium">${title}</span>
</div>
</button>
`).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
}; |