From ffbe9aabd7297e04156ac66e2502da31db28b8a8 Mon Sep 17 00:00:00 2001 From: bloodwiing Date: Tue, 21 May 2024 17:19:06 +0300 Subject: [PATCH] Fix: Firefox transition bugs --- src/comp/toast/toast.svelte | 108 ++++++++++++++++++++++++------------ src/routes/+layout.svelte | 2 +- 2 files changed, 73 insertions(+), 37 deletions(-) diff --git a/src/comp/toast/toast.svelte b/src/comp/toast/toast.svelte index 209d459..56b6f00 100644 --- a/src/comp/toast/toast.svelte +++ b/src/comp/toast/toast.svelte @@ -3,6 +3,8 @@ import Tablericon from "$comp/tablericon.svelte"; import { removeToast } from "$lib/memory/toast"; import { onMount } from "svelte"; + import { backOut, cubicOut, sineOut } from "svelte/easing"; + import { tweened } from "svelte/motion"; /** * @type {import("$lib/memory/toast").Toast} @@ -28,11 +30,51 @@ /** @type {boolean | null} */ let inserted = null; + $: expand, (() => { + if (!element) return; + + if (expand) { + show(); + } else { + hide(); + } + })(); + onMount(() => { height = element.getBoundingClientRect().height; inserted = true; }); + + /** @type {import("svelte/motion").Tweened} */ + var valueTween = createTween(0.0); + + /** + * @param {number} start + * @returns {import("svelte/motion").Tweened} + */ + function createTween(start) { + return tweened(start, { + duration: 200, + easing: cubicOut, + }); + } + + /** + * @param {number} goal + * @returns {Promise} + */ + async function runTween(goal) { + await valueTween.set(goal); + } + + export async function show() { + await runTween(1.0); + } + + export async function hide() { + await runTween(0.0); + } -