headpat fade in animation & style
This commit is contained in:
@@ -1,4 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { cubicOut } from "svelte/easing";
|
||||||
|
import { type TransitionConfig } from "svelte/transition";
|
||||||
|
|
||||||
|
function fadeSlide(
|
||||||
|
node: HTMLElement,
|
||||||
|
params: { duration: number }
|
||||||
|
): TransitionConfig {
|
||||||
|
const opacity = parseFloat(getComputedStyle(node).opacity);
|
||||||
|
return {
|
||||||
|
duration: params.duration,
|
||||||
|
easing: cubicOut,
|
||||||
|
css: (t) => `opacity: ${t * opacity}; transform: translateY(${(1 - t) * 20}px);`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
imageSrc,
|
imageSrc,
|
||||||
visible = $bindable(false),
|
visible = $bindable(false),
|
||||||
@@ -24,7 +39,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if visible}
|
{#if visible}
|
||||||
<div class="fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/80">
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex flex-col items-center justify-center bg-gradient-to-b from-transparent to-black/80"
|
||||||
|
transition:fadeSlide={{ duration: 300 }}
|
||||||
|
>
|
||||||
{#if senderName}
|
{#if senderName}
|
||||||
<div class="mb-4 text-white text-lg font-medium">{senderName} gave you a headpat!</div>
|
<div class="mb-4 text-white text-lg font-medium">{senderName} gave you a headpat!</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user