mirror of
https://github.com/isledecomp/isle.pizza.git
synced 2026-02-28 22:07:39 +00:00
- Replace vanilla JS with Svelte 5 components - Add Vite build system with Terser optimization - Reorganize assets into src/ and public/ directories - Update README with setup instructions
60 lines
1.7 KiB
Svelte
60 lines
1.7 KiB
Svelte
<script>
|
||
import { showGoodbyePopup, goodbyeProgress } from '../stores.js';
|
||
|
||
let timeout = null;
|
||
let interval = null;
|
||
|
||
$: if ($showGoodbyePopup) {
|
||
startCountdown();
|
||
}
|
||
|
||
function startCountdown() {
|
||
const duration = 4000;
|
||
const startTime = performance.now();
|
||
|
||
function animate(currentTime) {
|
||
const elapsed = currentTime - startTime;
|
||
const progress = Math.min(elapsed / duration, 1);
|
||
goodbyeProgress.set(progress * 100);
|
||
|
||
if (progress < 1) {
|
||
interval = requestAnimationFrame(animate);
|
||
}
|
||
}
|
||
|
||
interval = requestAnimationFrame(animate);
|
||
|
||
timeout = setTimeout(() => {
|
||
window.location.href = 'https://legoisland.org';
|
||
}, duration);
|
||
}
|
||
|
||
function cancel() {
|
||
if (timeout) {
|
||
clearTimeout(timeout);
|
||
timeout = null;
|
||
}
|
||
if (interval) {
|
||
cancelAnimationFrame(interval);
|
||
interval = null;
|
||
}
|
||
goodbyeProgress.set(0);
|
||
showGoodbyePopup.set(false);
|
||
}
|
||
</script>
|
||
|
||
{#if $showGoodbyePopup}
|
||
<div id="goodbye-popup" class="notification-popup">
|
||
<div class="notification-popup-content">
|
||
<button class="update-dismiss-btn" aria-label="Cancel" onclick={cancel}>×</button>
|
||
<div class="update-speech-bubble">
|
||
<p class="update-message">See you later, Brickulator!</p>
|
||
<div class="goodbye-progress">
|
||
<div class="goodbye-progress-bar" style="width: {$goodbyeProgress}%"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<img src="later.webp" alt="Goodbye" class="update-character" width="150" height="187">
|
||
</div>
|
||
{/if}
|