-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path404.html
More file actions
192 lines (178 loc) · 8.03 KB
/
404.html
File metadata and controls
192 lines (178 loc) · 8.03 KB
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
---
layout: default
title: 404 - Page Not Found
permalink: /404.html
---
<main role="main" class="nf-wrapper" aria-labelledby="nf-heading" aria-describedby="nf-text">
<div class="nf-card">
<div class="nf-emoji" aria-hidden="true">🚀</div>
<h1 id="nf-heading" class="nf-heading">404 – Page <span id="rocket-typed-anchor"></span> Not Found</h1>
<p id="nf-text" class="nf-text">Don't click the rocket...</p>
<div class="nf-actions">
<a class="nf-btn primary" href="{{ site.baseurl }}/index.html">Home</a>
<a class="nf-btn" href="{{ site.baseurl }}/blogs.html">Blog</a>
</div>
</div>
</main>
<script>
// Interactive rocket flight on click
(function(){
// === Rocket Flight Config (edit values or use exposed helpers before launch) ===
const CONFIG = {
baseNoseAngle: 45, // Emoji nose visual offset
exitMode: 'nose-offset', // 'nose-offset' | 'fixed'
exitOffsetDeg: 270, // Extra degrees added to facing when exitMode='nose-offset'
fixedExitAngleDeg: -90, // Used when exitMode='fixed' (e.g. -90 = up)
loops: 2, // Full loops before exit
durationMs: 4800, // Orbit duration
exitDurationMs: 1400, // Exit travel duration
radiusScale: 0.60, // Orbit radius vs diagonal
quickRadiusFraction: 0.50 // Backup radius vs min(vw,vh)
};
// Expose minimal helpers (badge removed)
window.ROCKET_CONFIG = CONFIG;
window.setRocketExitOffset = deg => { CONFIG.exitOffsetDeg = deg; console.log('exitOffsetDeg =', deg); };
window.setRocketExitMode = mode => { CONFIG.exitMode = mode; console.log('exitMode =', mode); };
const rocket = document.querySelector('.nf-emoji');
if(!rocket) return;
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)');
let launched = false;
let typedStarted = false;
function startTypedInsertion(){
if(typedStarted) return; typedStarted = true;
const anchor = document.getElementById('rocket-typed-anchor');
if(!anchor) return;
const phrase = '(and also rocket)';
const prefersReduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if(prefersReduce){
anchor.textContent = phrase;
return;
}
let index = 0;
function typeNext(){
if(index <= phrase.length){
anchor.textContent = phrase.slice(0, index);
index += 1;
setTimeout(typeNext, 55);
}
}
typeNext();
}
rocket.style.cursor='pointer';
rocket.setAttribute('role','button');
rocket.setAttribute('tabindex','0');
rocket.setAttribute('title','Launch the rocket');
function launchNoMotion(){
const rect = rocket.getBoundingClientRect();
const placeholder = document.createElement('div');
placeholder.style.height = rect.height + 'px';
placeholder.style.marginBottom = '1.5rem';
placeholder.className = 'nf-emoji-space';
rocket.parentNode.insertBefore(placeholder, rocket);
rocket.remove();
startTypedInsertion();
}
function launchFancy(){
const rect = rocket.getBoundingClientRect();
const placeholder = document.createElement('div');
placeholder.style.height = rect.height + 'px';
placeholder.style.marginBottom = '1.5rem';
placeholder.className = 'nf-emoji-space';
rocket.parentNode.insertBefore(placeholder, rocket);
const wrapper = document.createElement('div');
wrapper.style.position='fixed';
wrapper.style.left = rect.left + 'px';
wrapper.style.top = rect.top + 'px';
wrapper.style.width = rect.width + 'px';
wrapper.style.height = rect.height + 'px';
wrapper.style.zIndex = 4000;
wrapper.style.pointerEvents='none';
wrapper.style.willChange='transform';
rocket.parentNode.replaceChild(wrapper, rocket);
wrapper.appendChild(rocket);
rocket.style.animation='none';
rocket.style.willChange='transform';
// Fast large circular/spiral flight around the page
const vw = window.innerWidth, vh = window.innerHeight;
const centerX = vw / 2; const centerY = vh / 2;
const diag = Math.sqrt(vw*vw + vh*vh);
const startRect = wrapper.getBoundingClientRect();
const startCx = startRect.left + startRect.width/2;
const startCy = startRect.top + startRect.height/2;
const startDistance = Math.hypot(startCx - centerX, startCy - centerY);
// Larger target radius so path reaches near edges; clamp to avoid excessive off-screen travel
const targetRadius = Math.min(diag * CONFIG.radiusScale, Math.max(startDistance || 1, Math.min(vw, vh) * CONFIG.quickRadiusFraction));
const radiusDrift = Math.max(0, targetRadius - startDistance);
let startAngle = Math.atan2(startCy - centerY, startCx - centerX);
if(startDistance === 0){ startAngle = -Math.PI/2; }
const loops = CONFIG.loops; // number of loops
const extraArc = Math.PI * 0.35; // exit arc
const totalAngle = loops * Math.PI * 2 + extraArc;
const totalDuration = CONFIG.durationMs;
const startTime = performance.now();
const BASE_EMOJI_NOSE_ANGLE = CONFIG.baseNoseAngle; // emoji nose offset
let prevX = 0, prevY = 0; let frame = 0;
let lastVX = 0, lastVY = -1; let currentRotation = 0;
function easeInOut(t){ return t<0.5 ? 2*t*t : 1 - Math.pow(-2*t+2,2)/2; }
function easeOutCubic(t){ return 1 - Math.pow(1-t,3); }
function animate(now){
const elapsed = now - startTime;
let p = elapsed / totalDuration; if(p>1) p = 1;
const eased = easeInOut(p);
const ang = startAngle + eased * totalAngle;
// Bring radius to near target quickly (within first third of flight) for full-viewport coverage
const radialPhase = Math.min(1, p * 3);
const currentRadius = startDistance + radiusDrift * easeOutCubic(radialPhase);
const orbitX = centerX + currentRadius * Math.cos(ang);
const orbitY = centerY + currentRadius * Math.sin(ang);
const x = orbitX - startCx;
const y = orbitY - startCy;
if(frame === 0){ prevX = x; prevY = y; }
const vx = x - prevX; const vy = y - prevY;
if(vx*vx + vy*vy > 0.0001){ lastVX = vx; lastVY = vy; }
prevX = x; prevY = y; frame++;
wrapper.style.transform = `translate(${x}px, ${y}px)`;
// orient rocket along motion
const motionAngle = Math.atan2(lastVY, lastVX) * 180/Math.PI;
currentRotation = motionAngle - BASE_EMOJI_NOSE_ANGLE;
rocket.style.transform = `rotate(${currentRotation}deg)`;
if(p < 1){
requestAnimationFrame(animate);
} else {
// Exit: continue along current facing (tangent) direction
// Determine nose direction (rocket rotated by currentRotation, nose offset BASE_EMOJI_NOSE_ANGLE)
// Exit direction calculation (configurable)
let chosenAngleDeg;
if(CONFIG.exitMode === 'fixed'){
chosenAngleDeg = CONFIG.fixedExitAngleDeg;
} else {
chosenAngleDeg = currentRotation + BASE_EMOJI_NOSE_ANGLE + CONFIG.exitOffsetDeg;
}
const noseTheta = chosenAngleDeg * Math.PI / 180;
let dirX = Math.cos(noseTheta);
let dirY = Math.sin(noseTheta);
// Normalize (should already be unit length)
const mag = Math.hypot(dirX, dirY) || 1; dirX/=mag; dirY/=mag;
// Project far off-screen along nose heading
const exitDist = Math.max(diag, vh, vw) * 1.35;
const exitX = x + dirX * exitDist;
const exitY = y + dirY * exitDist;
wrapper.style.transition = `transform ${CONFIG.exitDurationMs}ms cubic-bezier(.65,.05,.36,1), opacity ${CONFIG.exitDurationMs}ms ease`;
rocket.style.transition = `transform ${CONFIG.exitDurationMs}ms cubic-bezier(.65,.05,.36,1)`;
wrapper.style.transform = `translate(${exitX}px, ${exitY}px)`;
// Keep current orientation (already aligned with motion) and add slight scale
rocket.style.transform = `rotate(${currentRotation}deg) scale(1.15)`;
wrapper.style.opacity = '0';
setTimeout(()=>{ wrapper.remove(); startTypedInsertion(); }, CONFIG.exitDurationMs);
}
}
requestAnimationFrame(animate);
}
function handleLaunch(){
if(launched) return; launched = true;
if(reduce.matches) launchNoMotion(); else launchFancy();
}
rocket.addEventListener('click', handleLaunch);
rocket.addEventListener('keydown', e => { if(e.key==='Enter' || e.key===' ') { e.preventDefault(); handleLaunch(); } });
})();
</script>