File size: 892 Bytes
29b64bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<script lang="ts">

    // Svelte
    import { createEventDispatcher } from 'svelte'

	// Libs
	import { gsap } from "gsap";

	// Types
	import type { Star } from "$lib/types/Star";

	// Props
	export let star: Star;

    // Variables
    const dispatch = createEventDispatcher()

	function starAnimation(node: any) {
		let deltaX = star.end.x - star.start.x;
		let deltaY = star.end.y - star.start.y;

		gsap.to(node, {
			translateX: deltaX,
			translateY: deltaY,
            height: 4,
            width: 4,
            opacity: 0,
			scaleY: 100,
			duration: 1.5,
            backgroundColor: "white",
			ease: "power1.inOut",
            onComplete: () => {
                dispatch("remove", star);
            }
		});
	}
</script>

<div
	use:starAnimation
	class="absolute w-[2px] h-[2px] bg-blue-400 rounded-full rotate-45"
	style="top: {star.start.y}px; left: {star.start.x}px"
/>