Skip to content

Commit 6e137c1

Browse files
committed
refactor footer delay script to enable mobile-specific functionality; add visual debug indicator for mobile users
1 parent 1373f30 commit 6e137c1

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<!-- <script src="./js/main.js" defer></script> -->
3434

3535
<!-- Footer Link Delay Script -->
36-
<script src="./js/footer-delay.js" defer></script>
36+
<script src="./js/footer-delay.js"></script>
3737
</head>
3838
<body>
3939
<div class="content-wrapper">

js/footer-delay.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,72 @@
33
* Adds a delay to footer links to allow crumple animations to play
44
*/
55

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+
742
const footerLinks = document.querySelectorAll('.footer a[href]');
43+
console.log('Found footer links:', footerLinks.length);
844

945
footerLinks.forEach(link => {
1046
link.addEventListener('click', function(e) {
47+
console.log('Footer link clicked:', this.getAttribute('href'));
48+
1149
// Don't delay if it's the same page or a hash link
1250
if (this.getAttribute('href').startsWith('#') ||
1351
this.getAttribute('href') === window.location.pathname) {
52+
console.log('Same page or hash link, no delay');
1453
return;
1554
}
1655

1756
e.preventDefault();
1857
const href = this.getAttribute('href');
58+
console.log('Delaying navigation to:', href);
1959

2060
// Add a small delay to show the crumple animation
2161
setTimeout(() => {
62+
console.log('Navigating to:', href);
2263
window.location.href = href;
2364
}, 800); // 800ms delay
2465
});
2566
});
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

Comments
 (0)