mirror of https://github.com/VERT-sh/VERT.git
parent
50d93c0273
commit
9031254e37
|
@ -1,4 +1,4 @@
|
||||||
import { isMobile } from "$lib/store/index.svelte";
|
import { isMobile, motion } from "$lib/store/index.svelte";
|
||||||
import type { AnimationConfig, FlipParams } from "svelte/animate";
|
import type { AnimationConfig, FlipParams } from "svelte/animate";
|
||||||
import { cubicOut } from "svelte/easing";
|
import { cubicOut } from "svelte/easing";
|
||||||
import {
|
import {
|
||||||
|
@ -8,19 +8,31 @@ import {
|
||||||
type FlyParams,
|
type FlyParams,
|
||||||
} from "svelte/transition";
|
} from "svelte/transition";
|
||||||
|
|
||||||
|
// Subscribe to stores
|
||||||
|
let motionEnabled = true;
|
||||||
|
let isMobileDevice = false;
|
||||||
|
|
||||||
|
motion.subscribe(value => {
|
||||||
|
motionEnabled = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
isMobile.subscribe(value => {
|
||||||
|
isMobileDevice = value;
|
||||||
|
});
|
||||||
|
|
||||||
export const 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)";
|
"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 const duration = 500;
|
||||||
|
|
||||||
export function fade(node: HTMLElement, options: FadeParams) {
|
export function fade(node: HTMLElement, options: FadeParams) {
|
||||||
if (localStorage.getItem("motion") === "false") return {};
|
if (!motionEnabled) return {};
|
||||||
const animation = svelteFade(node, options);
|
const animation = svelteFade(node, options);
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fly(node: HTMLElement, options: FlyParams) {
|
export function fly(node: HTMLElement, options: FlyParams) {
|
||||||
if (localStorage.getItem("motion") === "false" || isMobile) return {};
|
if (!motionEnabled || isMobileDevice) return {};
|
||||||
const animation = svelteFly(node, options);
|
const animation = svelteFly(node, options);
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Panel from "$lib/components/visual/Panel.svelte";
|
import Panel from "$lib/components/visual/Panel.svelte";
|
||||||
import { setMotion, setTheme } from "$lib/store/index.svelte";
|
import { motion, setMotion, setTheme } from "$lib/store/index.svelte";
|
||||||
import {
|
import {
|
||||||
MoonIcon,
|
MoonIcon,
|
||||||
PaletteIcon,
|
PaletteIcon,
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
updateTheme();
|
updateTheme();
|
||||||
|
|
||||||
if (localStorage.getItem("motion") === "true") {
|
if ($motion) {
|
||||||
enableMotionElement.classList.add("selected");
|
enableMotionElement.classList.add("selected");
|
||||||
disableMotionElement.classList.remove("selected");
|
disableMotionElement.classList.remove("selected");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -183,12 +183,13 @@ export function setTheme(theme: "light" | "dark") {
|
||||||
log(["theme"], `set to ${theme}`);
|
log(["theme"], `set to ${theme}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setMotion(motion: boolean) {
|
export function setMotion(motionEnabled: boolean) {
|
||||||
localStorage.setItem("motion", motion.toString());
|
localStorage.setItem("motion", motionEnabled.toString());
|
||||||
window.plausible("Motion set", {
|
window.plausible("Motion set", {
|
||||||
props: { motion },
|
props: { motion: motionEnabled },
|
||||||
});
|
});
|
||||||
log(["motion"], `set to ${motion}`);
|
log(["motion"], `set to ${motionEnabled}`);
|
||||||
|
motion.set(motionEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const files = new Files();
|
export const files = new Files();
|
||||||
|
@ -196,3 +197,5 @@ export const showGradient = writable(true);
|
||||||
export const gradientColor = writable("");
|
export const gradientColor = writable("");
|
||||||
|
|
||||||
export const isMobile = writable(false);
|
export const isMobile = writable(false);
|
||||||
|
export const isFirefox = writable(false);
|
||||||
|
export const motion = writable(true);
|
|
@ -14,6 +14,7 @@
|
||||||
files,
|
files,
|
||||||
gradientColor,
|
gradientColor,
|
||||||
isMobile,
|
isMobile,
|
||||||
|
motion,
|
||||||
showGradient,
|
showGradient,
|
||||||
} from "$lib/store/index.svelte";
|
} from "$lib/store/index.svelte";
|
||||||
import {
|
import {
|
||||||
|
@ -24,9 +25,9 @@
|
||||||
} from "lucide-svelte";
|
} from "lucide-svelte";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { quintOut } from "svelte/easing";
|
import { quintOut } from "svelte/easing";
|
||||||
import { writable } from "svelte/store";
|
|
||||||
import "../app.scss";
|
import "../app.scss";
|
||||||
let { children, data } = $props();
|
import { writable } from 'svelte/store';
|
||||||
|
let { children } = $props();
|
||||||
|
|
||||||
let shouldGoBack = writable(false);
|
let shouldGoBack = writable(false);
|
||||||
let navbar = $state<HTMLDivElement>();
|
let navbar = $state<HTMLDivElement>();
|
||||||
|
@ -88,9 +89,11 @@
|
||||||
navbar?.addEventListener("mouseleave", mouseLeave);
|
navbar?.addEventListener("mouseleave", mouseLeave);
|
||||||
|
|
||||||
isMobile.set(window.innerWidth <= 768);
|
isMobile.set(window.innerWidth <= 768);
|
||||||
document.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
isMobile.set(window.innerWidth <= 768);
|
isMobile.set(window.innerWidth <= 768);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
motion.set(localStorage.getItem("motion") === "true");
|
||||||
});
|
});
|
||||||
|
|
||||||
let goingLeft = $state(false);
|
let goingLeft = $state(false);
|
||||||
|
@ -169,12 +172,12 @@
|
||||||
in:fade={{
|
in:fade={{
|
||||||
duration,
|
duration,
|
||||||
easing: quintOut,
|
easing: quintOut,
|
||||||
delay: 100,
|
delay: isMobile ? 0 : 100,
|
||||||
}}
|
}}
|
||||||
out:fade={{
|
out:fade={{
|
||||||
duration,
|
duration,
|
||||||
easing: quintOut,
|
easing: quintOut,
|
||||||
delay: 200,
|
delay: isMobile ? 0 : 200,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="flex flex-col h-full pb-36 md:pb-0">
|
<div class="flex flex-col h-full pb-36 md:pb-0">
|
||||||
|
|
Loading…
Reference in New Issue