File size: 10,645 Bytes
42538c9 | 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | // Main JavaScript for TestComix
document.addEventListener('DOMContentLoaded', function() {
// Initialize components
initComicPanels();
initNextChapterButton();
initPanelInteractions();
// Add parallax effect to background
initParallaxEffect();
// Initialize tooltips for icons (if any)
initTooltips();
});
function initComicPanels() {
const panels = document.querySelectorAll('.comic-panel');
panels.forEach((panel, index) => {
// Add staggered entrance animation
panel.style.opacity = '0';
panel.style.transform = 'translateY(30px)';
setTimeout(() => {
panel.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
panel.style.opacity = '1';
panel.style.transform = 'translateY(0)';
}, 200 * index);
// Add click effect
panel.addEventListener('click', function() {
const panelNumber = this.getAttribute('data-panel');
showPanelDetails(panelNumber);
});
});
}
function showPanelDetails(panelNumber) {
const panelTitles = {
'1': 'THE DAWN',
'2': 'THE CONVERGENCE',
'3': 'THE BEYOND'
};
const panelDescriptions = {
'1': 'A breathtaking display of colors awakening from their digital slumber. This panel represents the beginning of our visual journey.',
'2': 'The explosive meeting point of urban reality and digital fantasy. Watch as worlds collide in spectacular fashion.',
'3': 'Venture into the unknown territories of imagination where anything is possible and every pixel tells a story.'
};
// Create modal for panel details
const modal = document.createElement('div');
modal.className = 'fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4';
modal.style.backdropFilter = 'blur(10px)';
modal.innerHTML = `
<div class="bg-gradient-to-br from-gray-900 to-gray-800 rounded-2xl max-w-2xl w-full border-2 border-electric-500/30 overflow-hidden">
<div class="p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-3xl font-bold bg-gradient-to-r from-electric-300 to-neon-300 bg-clip-text text-transparent">
PANEL ${panelNumber}: ${panelTitles[panelNumber]}
</h3>
<button class="close-modal text-gray-400 hover:text-white transition-colors">
<i data-feather="x" class="w-6 h-6"></i>
</button>
</div>
<div class="aspect-video rounded-lg overflow-hidden mb-6">
<img src="http://static.photos/${panelNumber === '1' ? 'gradient' : panelNumber === '2' ? 'cityscape' : 'abstract'}/1024x576/${panelNumber}0${panelNumber}"
class="w-full h-full object-cover"
alt="${panelTitles[panelNumber]}">
</div>
<p class="text-gray-300 text-lg mb-6">${panelDescriptions[panelNumber]}</p>
<div class="flex items-center justify-between">
<div class="flex space-x-2">
<span class="px-3 py-1 rounded-full bg-electric-500/20 text-electric-300 text-sm">Comic Art</span>
<span class="px-3 py-1 rounded-full bg-neon-500/20 text-neon-300 text-sm">Digital</span>
<span class="px-3 py-1 rounded-full bg-purple-500/20 text-purple-300 text-sm">${panelNumber === '1' ? 'Abstract' : panelNumber === '2' ? 'Urban' : 'Fantasy'}</span>
</div>
<button class="bg-gradient-to-r from-electric-500 to-neon-500 hover:from-electric-600 hover:to-neon-600 text-white font-medium py-2 px-6 rounded-full transition-all duration-300 transform hover:scale-105">
<i data-feather="download" class="w-4 h-4 inline-block mr-2"></i>
Download Panel
</button>
</div>
</div>
</div>
`;
document.body.appendChild(modal);
// Replace feather icons in modal
feather.replace();
// Close modal functionality
const closeBtn = modal.querySelector('.close-modal');
closeBtn.addEventListener('click', () => {
modal.style.opacity = '0';
setTimeout(() => {
document.body.removeChild(modal);
}, 300);
});
// Close on background click
modal.addEventListener('click', (e) => {
if (e.target === modal) {
modal.style.opacity = '0';
setTimeout(() => {
document.body.removeChild(modal);
}, 300);
}
});
// Animate modal entrance
setTimeout(() => {
modal.style.opacity = '1';
modal.style.transition = 'opacity 0.3s ease';
}, 10);
}
function initNextChapterButton() {
const nextChapterBtn = document.getElementById('nextChapterBtn');
if (nextChapterBtn) {
nextChapterBtn.addEventListener('click', function() {
// Add click animation
this.style.transform = 'scale(0.95)';
// Show loading state
const originalText = this.innerHTML;
this.innerHTML = '<span class="flex items-center justify-center"><i data-feather="loader" class="w-5 h-5 mr-2 animate-spin"></i>Loading Next Chapter...</span>';
feather.replace();
// Simulate loading
setTimeout(() => {
this.innerHTML = originalText;
this.style.transform = 'scale(1)';
feather.replace();
// Show notification
showNotification('Coming Soon: Chapter II! Stay tuned for more visual adventures.');
}, 1500);
});
}
}
function initPanelInteractions() {
// Add keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
const panels = document.querySelectorAll('.comic-panel');
const focusedPanel = document.querySelector('.comic-panel:focus');
if (focusedPanel) {
const currentIndex = Array.from(panels).indexOf(focusedPanel);
let nextIndex;
if (e.key === 'ArrowRight') {
nextIndex = (currentIndex + 1) % panels.length;
} else {
nextIndex = (currentIndex - 1 + panels.length) % panels.length;
}
panels[nextIndex].focus();
panels[nextIndex].scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}
});
}
function initParallaxEffect() {
// Create subtle parallax effect on scroll
const hero = document.querySelector('h1');
const panels = document.querySelectorAll('.comic-panel');
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
if (hero) {
hero.style.transform = `translateY(${scrolled * 0.1}px)`;
}
panels.forEach((panel, index) => {
const speed = 0.05 + (index * 0.02);
panel.style.transform = `translateY(${scrolled * speed}px) scale(${1 - (scrolled * 0.0001)})`;
});
});
}
function initTooltips() {
// Initialize tooltips for interactive elements
const tooltipElements = document.querySelectorAll('[data-tooltip]');
tooltipElements.forEach(element => {
element.addEventListener('mouseenter', (e) => {
const tooltipText = e.target.getAttribute('data-tooltip');
const tooltip = document.createElement('div');
tooltip.className = 'absolute bg-gray-900 text-white text-sm px-3 py-2 rounded-lg shadow-xl z-50';
tooltip.textContent = tooltipText;
const rect = e.target.getBoundingClientRect();
tooltip.style.top = `${rect.top - 40}px`;
tooltip.style.left = `${rect.left + rect.width / 2}px`;
tooltip.style.transform = 'translateX(-50%)';
document.body.appendChild(tooltip);
e.target._tooltip = tooltip;
});
element.addEventListener('mouseleave', (e) => {
if (e.target._tooltip) {
document.body.removeChild(e.target._tooltip);
delete e.target._tooltip;
}
});
});
}
function showNotification(message) {
// Create notification element
const notification = document.createElement('div');
notification.className = 'fixed top-4 right-4 bg-gradient-to-r from-electric-500 to-neon-500 text-white px-6 py-3 rounded-lg shadow-xl z-50 transform translate-x-full transition-transform duration-500';
notification.textContent = message;
notification.innerHTML = `
<div class="flex items-center">
<i data-feather="bell" class="w-5 h-5 mr-3"></i>
<span>${message}</span>
</div>
`;
document.body.appendChild(notification);
feather.replace();
// Animate in
setTimeout(() => {
notification.style.transform = 'translateX(0)';
}, 10);
// Auto-remove after 5 seconds
setTimeout(() => {
notification.style.transform = 'translateX(100%)';
setTimeout(() => {
document.body.removeChild(notification);
}, 500);
}, 5000);
}
// Utility function to check if element is in viewport
function isElementInViewport(el) {
const rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
// Add hover sound effect for panels (optional)
function addHoverSoundEffect() {
const panels = document.querySelectorAll('.comic-panel');
const hoverSound = new Audio('data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAA=='); // Silent audio as placeholder
panels.forEach(panel => {
panel.addEventListener('mouseenter', () => {
hoverSound.currentTime = 0;
hoverSound.volume = 0.1;
hoverSound.play().catch(e => console.log('Audio play failed:', e));
});
});
} |