|
3 | 3 | * Adds a delay to footer links to allow crumple animations to play |
4 | 4 | */ |
5 | 5 |
|
6 | | -document.addEventListener('DOMContentLoaded', function() { |
| 6 | +function initFooterDelay() { |
| 7 | + // Only apply delay on mobile devices |
| 8 | + const isMobile = window.matchMedia("only screen and (max-width: 850px)").matches || |
| 9 | + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); |
| 10 | + |
| 11 | + if (!isMobile) { |
| 12 | + console.log('Desktop detected - no delay needed'); |
| 13 | + return; |
| 14 | + } |
| 15 | + |
| 16 | + console.log('Mobile detected - footer delay enabled'); |
| 17 | + |
| 18 | + // Add visual debug indicator |
| 19 | + const debugIndicator = document.createElement('div'); |
| 20 | + debugIndicator.innerHTML = '📱 Mobile delay active'; |
| 21 | + debugIndicator.style.cssText = ` |
| 22 | + position: fixed; |
| 23 | + top: 10px; |
| 24 | + right: 10px; |
| 25 | + background: rgba(0,0,0,0.8); |
| 26 | + color: white; |
| 27 | + padding: 8px 12px; |
| 28 | + border-radius: 4px; |
| 29 | + font-size: 12px; |
| 30 | + z-index: 9999; |
| 31 | + font-family: monospace; |
| 32 | + `; |
| 33 | + document.body.appendChild(debugIndicator); |
| 34 | + |
| 35 | + // Remove debug indicator after 3 seconds |
| 36 | + setTimeout(() => { |
| 37 | + if (debugIndicator.parentNode) { |
| 38 | + debugIndicator.parentNode.removeChild(debugIndicator); |
| 39 | + } |
| 40 | + }, 3000); |
| 41 | + |
7 | 42 | const footerLinks = document.querySelectorAll('.footer a[href]'); |
| 43 | + console.log('Found footer links:', footerLinks.length); |
8 | 44 |
|
9 | 45 | footerLinks.forEach(link => { |
10 | 46 | link.addEventListener('click', function(e) { |
| 47 | + console.log('Footer link clicked:', this.getAttribute('href')); |
| 48 | + |
11 | 49 | // Don't delay if it's the same page or a hash link |
12 | 50 | if (this.getAttribute('href').startsWith('#') || |
13 | 51 | this.getAttribute('href') === window.location.pathname) { |
| 52 | + console.log('Same page or hash link, no delay'); |
14 | 53 | return; |
15 | 54 | } |
16 | 55 |
|
17 | 56 | e.preventDefault(); |
18 | 57 | const href = this.getAttribute('href'); |
| 58 | + console.log('Delaying navigation to:', href); |
19 | 59 |
|
20 | 60 | // Add a small delay to show the crumple animation |
21 | 61 | setTimeout(() => { |
| 62 | + console.log('Navigating to:', href); |
22 | 63 | window.location.href = href; |
23 | 64 | }, 800); // 800ms delay |
24 | 65 | }); |
25 | 66 | }); |
26 | | -}); |
| 67 | +} |
| 68 | + |
| 69 | +// Run immediately if DOM is ready, otherwise wait for DOMContentLoaded |
| 70 | +if (document.readyState === 'loading') { |
| 71 | + document.addEventListener('DOMContentLoaded', initFooterDelay); |
| 72 | +} else { |
| 73 | + initFooterDelay(); |
| 74 | +} |
0 commit comments