From d3cba40dbb95cc719609fdfe0cf4ab429ab9e197 Mon Sep 17 00:00:00 2001 From: JovannMC Date: Tue, 21 Jan 2025 20:04:27 +0300 Subject: [PATCH] Add motion settings --- src/lib/animation/index.ts | 18 ++++++ src/lib/components/functional/Dropdown.svelte | 3 +- .../components/functional/FancyMenu.svelte | 3 +- src/lib/components/functional/Navbar.svelte | 3 +- src/lib/sections/settings/Appearance.svelte | 63 ++++++++++++++++--- src/lib/store/index.svelte.ts | 8 +++ src/routes/+layout.svelte | 2 +- src/routes/convert/+page.svelte | 3 +- 8 files changed, 87 insertions(+), 16 deletions(-) diff --git a/src/lib/animation/index.ts b/src/lib/animation/index.ts index c201fa9..466868a 100644 --- a/src/lib/animation/index.ts +++ b/src/lib/animation/index.ts @@ -1,11 +1,29 @@ import type { AnimationConfig, FlipParams } from "svelte/animate"; import { cubicOut } from "svelte/easing"; +import { + fade as svelteFade, + fly as svelteFly, + type FadeParams, + type FlyParams, +} from "svelte/transition"; export const transition = "linear(0,0.006,0.025 2.8%,0.101 6.1%,0.539 18.9%,0.721 25.3%,0.849 31.5%,0.937 38.1%,0.968 41.8%,0.991 45.7%,1.006 50.1%,1.015 55%,1.017 63.9%,1.001)"; export const duration = 500; +export function fade(node: HTMLElement, options: FadeParams) { + if (localStorage.getItem("motion") === "false") return {}; + const animation = svelteFade(node, options); + return animation; +} + +export function fly(node: HTMLElement, options: FlyParams) { + if (localStorage.getItem("motion") === "false") return {}; + const animation = svelteFly(node, options); + return animation; +} + // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type export function is_function(thing: unknown): thing is Function { return typeof thing === "function"; diff --git a/src/lib/components/functional/Dropdown.svelte b/src/lib/components/functional/Dropdown.svelte index 57fec3a..515bdd4 100644 --- a/src/lib/components/functional/Dropdown.svelte +++ b/src/lib/components/functional/Dropdown.svelte @@ -1,9 +1,8 @@