SUMMARY: Implemented Phase 3 Task 3.5: Page Transitions - smooth fade transitions between pages for improved perceived performance and user experience. CHANGES: 1. Created page-transitions.js (new): - PageTransitions class with fade out/in effects - Attaches to all internal links automatically - Excludes external links, downloads, and hash links - Respects Ctrl/Cmd+click for new tab behavior - 300ms transition duration - Console logging for debugging 2. Updated tractatus-theme.css: - Added page transition CSS section - body fade-in/fade-out classes - Respects prefers-reduced-motion for accessibility - Smooth 0.3s opacity transitions 3. Added script to key pages: - public/index.html - public/architecture.html - public/about.html - public/researcher.html - public/leader.html - public/implementer.html 4. Regenerated tractatus-theme.min.css with new transitions FEATURES: ✓ Smooth fade-out when clicking internal links ✓ Fade-in on page load ✓ Maintains navbar/footer during transition ✓ Improves perceived performance ✓ Accessible (respects reduced motion preference) ✓ Doesn't break Ctrl+click or right-click UI_TRANSFORMATION_PROJECT_PLAN.md: ✓ Phase 3 Task 3.5: Page Transitions (COMPLETED) 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2 KiB
JavaScript
78 lines
2 KiB
JavaScript
/**
|
|
* Page Transitions
|
|
* Tractatus Framework - Phase 3: Page Transitions
|
|
*
|
|
* Provides smooth fade transitions between pages for better UX
|
|
*/
|
|
|
|
class PageTransitions {
|
|
constructor() {
|
|
this.transitionDuration = 300; // milliseconds
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
// Add fade-in class to body on page load
|
|
document.body.classList.add('page-fade-in');
|
|
|
|
// Attach click handlers to internal links
|
|
this.attachLinkHandlers();
|
|
|
|
console.log('[PageTransitions] Initialized');
|
|
}
|
|
|
|
attachLinkHandlers() {
|
|
// Get all internal links (href starts with / or is relative)
|
|
const links = document.querySelectorAll('a[href^="/"], a[href^="./"], a[href^="../"]');
|
|
|
|
links.forEach(link => {
|
|
// Skip if link has target="_blank" or download attribute
|
|
if (link.getAttribute('target') === '_blank' || link.hasAttribute('download')) {
|
|
return;
|
|
}
|
|
|
|
link.addEventListener('click', (e) => {
|
|
// Allow Ctrl/Cmd+click to open in new tab
|
|
if (e.ctrlKey || e.metaKey || e.shiftKey) {
|
|
return;
|
|
}
|
|
|
|
// Skip if link has hash (same-page navigation)
|
|
const href = link.getAttribute('href');
|
|
if (href && href.startsWith('#')) {
|
|
return;
|
|
}
|
|
|
|
e.preventDefault();
|
|
this.transitionToPage(link.href);
|
|
});
|
|
});
|
|
|
|
console.log(`[PageTransitions] Attached handlers to ${links.length} links`);
|
|
}
|
|
|
|
transitionToPage(url) {
|
|
// Remove fade-in, add fade-out
|
|
document.body.classList.remove('page-fade-in');
|
|
document.body.classList.add('page-fade-out');
|
|
|
|
// Navigate after fade-out completes
|
|
setTimeout(() => {
|
|
window.location.href = url;
|
|
}, this.transitionDuration);
|
|
}
|
|
}
|
|
|
|
// Initialize on DOM ready
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
new PageTransitions();
|
|
});
|
|
} else {
|
|
new PageTransitions();
|
|
}
|
|
|
|
// Export for module systems
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = PageTransitions;
|
|
}
|