From 191e1ef8470a6ff52b7a773a72d8e03a06dd9312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 5 Aug 2024 16:28:14 +0200 Subject: [PATCH] refactor: rethink ProcessStep transition + use tick in transitions --- apps/website/src/animations/transitions.ts | 56 ++++++++++--------- .../molecules/ProcessStep/ProcessStep.svelte | 7 +-- .../src/routes/(site)/about/+page.svelte | 29 +++++----- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/apps/website/src/animations/transitions.ts b/apps/website/src/animations/transitions.ts index df45e23..a7ba82f 100644 --- a/apps/website/src/animations/transitions.ts +++ b/apps/website/src/animations/transitions.ts @@ -9,24 +9,25 @@ import { quartOut } from './easings' export const scaleFade = (node: HTMLElement, { scale = [0.7, 1], opacity = [1, 0], - x = null, + x = [0, 0], delay = 0, - duration = 1, + duration = 0.75, }): TransitionConfig => { - return { - css: () => { - animate(node, { - scale, - opacity, - x, - z: 0, - }, { - easing: quartOut, - duration, - delay, - }) + const anim = animate(node, { + scale, + opacity, + x, + z: 0, + }, { + easing: quartOut, + duration, + delay, + }) - return null + return { + duration: anim.duration * 1000, + tick: (t) => { + anim.currentTime = t } } } @@ -42,19 +43,20 @@ export const revealSplit = (node: HTMLElement, { duration = 1, delay = 0, }): TransitionConfig => { - return { - css: () => { - animate(node.querySelectorAll(children), { - opacity, - y, - z: 0, - }, { - easing: quartOut, - duration, - delay: stagger(0.04, { start: delay }), - }) + const anim = animate(node.querySelectorAll(children), { + opacity, + y, + z: 0, + }, { + easing: quartOut, + duration, + delay: stagger(0.04, { start: delay }), + }) - return null + return { + duration: anim.duration * 1000, + tick: (t) => { + anim.currentTime = t } } } diff --git a/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte b/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte index 2ca6951..41b1a4e 100644 --- a/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte +++ b/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte @@ -3,18 +3,18 @@