mirror of
https://github.com/BradNut/svelte-3d
synced 2025-09-08 17:40:17 +00:00
40 lines
678 B
Svelte
40 lines
678 B
Svelte
<script>
|
|
import { fly } from 'svelte/transition';
|
|
import Star from '$lib/Star.svelte'
|
|
|
|
let isStar = false;
|
|
|
|
function hitButton() {
|
|
isStar = true;
|
|
setTimeout(() => {
|
|
isStar = false;
|
|
}, 40);
|
|
}
|
|
</script>
|
|
|
|
<header>
|
|
<h1>Star World</h1>
|
|
</header>
|
|
|
|
<div style:position="relative">
|
|
{#if isStar}
|
|
<div class="star" out:fly={{ opacity: 0, y: -100, duration: 3000 }}>
|
|
<Star />
|
|
</div>
|
|
{/if}
|
|
<button on:click={hitButton}>Level Up</button>
|
|
</div>
|
|
|
|
<style>
|
|
header {
|
|
display: flex;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
margin-bottom: 60px;
|
|
}
|
|
|
|
.star {
|
|
position: absolute;
|
|
top: -30px;
|
|
z-index: -1;
|
|
}
|
|
</style>
|