diff --git a/src/lib/components/visual/effects/ProgressiveBlur.svelte b/src/lib/components/visual/effects/ProgressiveBlur.svelte index 1bdc6d3..f16cc42 100644 --- a/src/lib/components/visual/effects/ProgressiveBlur.svelte +++ b/src/lib/components/visual/effects/ProgressiveBlur.svelte @@ -47,7 +47,7 @@ class="absolute w-full h-full" style=" z-index: {index + 2}; - backdrop-filter: blur({blurIntensity}px); + backdrop-filter: blur( calc({blurIntensity}px * var(--blur-amount, 1)) ); mask: {mask}; " > @@ -63,6 +63,6 @@ >
diff --git a/src/lib/types/file.svelte.ts b/src/lib/types/file.svelte.ts index fcf1a24..d82d0ff 100644 --- a/src/lib/types/file.svelte.ts +++ b/src/lib/types/file.svelte.ts @@ -16,18 +16,21 @@ export class VertFile { public to = $state(""); + public blobUrl = $state(); + public converter: Converter | null = null; constructor( public readonly file: File, to: string, converter?: Converter, - public readonly blobUrl?: string, + blobUrl?: string, ) { this.to = to; this.converter = converter ?? null; this.convert = this.convert.bind(this); this.download = this.download.bind(this); + this.blobUrl = blobUrl; } public async convert() { diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 3e24f66..c5281f1 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -11,8 +11,10 @@ export const load = ({ url, request, cookies }) => { const { pathname } = url; const ua = request.headers.get("user-agent"); const isMobile = /mobile/i.test(ua || ""); + const isFirefox = /firefox/i.test(ua || ""); return { pathname, isMobile, + isFirefox, }; }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 8f37d00..0c4d52f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -63,49 +63,35 @@ img.onerror = async () => { // resolve(new VertFile(f, to, converter)); const reader = new FileReader(); + const file = new VertFile(f, to, converter); + resolve(file); reader.onload = async (e) => { - try { - const tags = await new Promise( - (resolve, reject) => { - jsmediatags.read( - new Blob([ - new Uint8Array( - e.target - ?.result as ArrayBuffer, - ), - ]), - { - onSuccess: (tag) => - resolve(tag), - onError: (error) => - reject(error), - }, - ); - }, - ); - console.log(tags); - const picture = tags.tags.picture; - if (!picture) { - resolve(new VertFile(f, to, converter)); - return; - } - const blob = new Blob( - [new Uint8Array(picture.data)], - { - type: picture.format, - }, - ); - resolve( - new VertFile( - f, - to, - converter, - URL.createObjectURL(blob), - ), - ); - } catch { - resolve(new VertFile(f, to, converter)); - } + const tags = await new Promise( + (resolve, reject) => { + jsmediatags.read( + new Blob([ + new Uint8Array( + e.target?.result as ArrayBuffer, + ), + ]), + { + onSuccess: (tag) => resolve(tag), + onError: (error) => reject(error), + }, + ); + }, + ); + const picture = tags.tags.picture; + if (!picture) return; + + const blob = new Blob( + [new Uint8Array(picture.data)], + { + type: picture.format, + }, + ); + const url = URL.createObjectURL(blob); + file.blobUrl = url; }; reader.readAsArrayBuffer(f); }; diff --git a/src/routes/convert/+page.svelte b/src/routes/convert/+page.svelte index a577bec..667d0d0 100644 --- a/src/routes/convert/+page.svelte +++ b/src/routes/convert/+page.svelte @@ -13,6 +13,13 @@ import { ArrowRight, Disc2Icon, FileAudioIcon, XIcon } from "lucide-svelte"; import { onMount } from "svelte"; import { quintOut } from "svelte/easing"; + import { + fade, + type EasingFunction, + type TransitionConfig, + } from "svelte/transition"; + + const { data } = $props(); const reversedFiles = $derived(files.files.slice().reverse()); @@ -131,6 +138,33 @@ files.files = []; goto("/"); }; + + export const progBlur = ( + _: HTMLElement, + config: + | Partial<{ + duration: number; + easing: EasingFunction; + }> + | undefined, + dir: { + direction: "in" | "out" | "both"; + }, + ): TransitionConfig => { + const prefersReducedMotion = window.matchMedia( + "(prefers-reduced-motion: reduce)", + ).matches; + if (!config) config = {}; + if (!config.duration) config.duration = 300; + if (!config.easing) config.easing = quintOut; + return { + duration: prefersReducedMotion ? 0 : config?.duration || 300, + css: (t) => { + return "--blur-amount: " + (dir.direction !== "in" ? t : 1 - t); + }, + easing: config?.easing, + }; + }; @@ -279,7 +313,9 @@ )} style="background-color: color-mix(in srgb, var(--{file.result ? 'accent-bg' - : 'bg'}), transparent var(--transparency)); backdrop-filter: blur(18px);" + : 'bg'}), transparent var(--transparency)); backdrop-filter: blur({data.isFirefox + ? 0 + : 18}px);" >