mirror of https://github.com/VERT-sh/VERT.git
feat: use will-change to optimize transforms (#25)
This commit is contained in:
parent
f06754e0f7
commit
0d82f3650c
|
@ -14,6 +14,7 @@
|
||||||
let { options, selected = $bindable(), onselect }: Props = $props();
|
let { options, selected = $bindable(), onselect }: Props = $props();
|
||||||
|
|
||||||
let open = $state(false);
|
let open = $state(false);
|
||||||
|
let hover = $state(false);
|
||||||
let isUp = $state(false);
|
let isUp = $state(false);
|
||||||
let dropdown = $state<HTMLDivElement>();
|
let dropdown = $state<HTMLDivElement>();
|
||||||
|
|
||||||
|
@ -50,6 +51,8 @@
|
||||||
<button
|
<button
|
||||||
class="font-display w-full min-w-fit justify-between overflow-hidden relative cursor-pointer px-3 border-2 border-solid flex items-center bg-background border-foreground-muted-alt rounded-xl p-2 focus:!outline-none"
|
class="font-display w-full min-w-fit justify-between overflow-hidden relative cursor-pointer px-3 border-2 border-solid flex items-center bg-background border-foreground-muted-alt rounded-xl p-2 focus:!outline-none"
|
||||||
onclick={toggle}
|
onclick={toggle}
|
||||||
|
onmouseenter={() => (hover = true)}
|
||||||
|
onmouseleave={() => (hover = false)}
|
||||||
>
|
>
|
||||||
<!-- <p>{selected}</p> -->
|
<!-- <p>{selected}</p> -->
|
||||||
<div
|
<div
|
||||||
|
@ -105,6 +108,7 @@
|
||||||
</button>
|
</button>
|
||||||
{#if open}
|
{#if open}
|
||||||
<div
|
<div
|
||||||
|
style={hover ? "will-change: opacity, blur, transform" : ""}
|
||||||
transition:blur={{
|
transition:blur={{
|
||||||
duration,
|
duration,
|
||||||
easing: quintOut,
|
easing: quintOut,
|
||||||
|
|
|
@ -12,9 +12,12 @@
|
||||||
import { MoonIcon, SunIcon } from "lucide-svelte";
|
import { MoonIcon, SunIcon } from "lucide-svelte";
|
||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
import JSCookie from "js-cookie";
|
import JSCookie from "js-cookie";
|
||||||
|
import { onMount } from "svelte";
|
||||||
let { children, data } = $props();
|
let { children, data } = $props();
|
||||||
|
|
||||||
let shouldGoBack = writable(false);
|
let shouldGoBack = writable(false);
|
||||||
|
let navbar = $state<HTMLDivElement>();
|
||||||
|
let hover = $state(false);
|
||||||
|
|
||||||
const links = $derived<
|
const links = $derived<
|
||||||
{
|
{
|
||||||
|
@ -70,6 +73,19 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const mouseEnter = () => {
|
||||||
|
hover = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const mouseLeave = () => {
|
||||||
|
hover = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
navbar?.addEventListener("mouseenter", mouseEnter);
|
||||||
|
navbar?.addEventListener("mouseleave", mouseLeave);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
@ -102,6 +118,7 @@
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="w-full max-w-screen-md p-1 border-solid border-2 rounded-2xl border-foreground-muted-alt flex mb-10 mx-auto lg:mt-5"
|
class="w-full max-w-screen-md p-1 border-solid border-2 rounded-2xl border-foreground-muted-alt flex mb-10 mx-auto lg:mt-5"
|
||||||
|
bind:this={navbar}
|
||||||
>
|
>
|
||||||
<div class="md:p-1">
|
<div class="md:p-1">
|
||||||
<a
|
<a
|
||||||
|
@ -200,6 +217,7 @@
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<div
|
<div
|
||||||
class="absolute top-0 left-0 w-full"
|
class="absolute top-0 left-0 w-full"
|
||||||
|
style={hover ? "will-change: opacity, blur, transform" : ""}
|
||||||
in:blur={{
|
in:blur={{
|
||||||
duration,
|
duration,
|
||||||
easing: quintOut,
|
easing: quintOut,
|
||||||
|
|
Loading…
Reference in New Issue