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 open = $state(false);
|
||||
let hover = $state(false);
|
||||
let isUp = $state(false);
|
||||
let dropdown = $state<HTMLDivElement>();
|
||||
|
||||
|
@ -50,6 +51,8 @@
|
|||
<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"
|
||||
onclick={toggle}
|
||||
onmouseenter={() => (hover = true)}
|
||||
onmouseleave={() => (hover = false)}
|
||||
>
|
||||
<!-- <p>{selected}</p> -->
|
||||
<div
|
||||
|
@ -105,6 +108,7 @@
|
|||
</button>
|
||||
{#if open}
|
||||
<div
|
||||
style={hover ? "will-change: opacity, blur, transform" : ""}
|
||||
transition:blur={{
|
||||
duration,
|
||||
easing: quintOut,
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
import { MoonIcon, SunIcon } from "lucide-svelte";
|
||||
import { browser } from "$app/environment";
|
||||
import JSCookie from "js-cookie";
|
||||
import { onMount } from "svelte";
|
||||
let { children, data } = $props();
|
||||
|
||||
let shouldGoBack = writable(false);
|
||||
let navbar = $state<HTMLDivElement>();
|
||||
let hover = $state(false);
|
||||
|
||||
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>
|
||||
|
||||
<svelte:head>
|
||||
|
@ -102,6 +118,7 @@
|
|||
|
||||
<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"
|
||||
bind:this={navbar}
|
||||
>
|
||||
<div class="md:p-1">
|
||||
<a
|
||||
|
@ -200,6 +217,7 @@
|
|||
<div class="w-full">
|
||||
<div
|
||||
class="absolute top-0 left-0 w-full"
|
||||
style={hover ? "will-change: opacity, blur, transform" : ""}
|
||||
in:blur={{
|
||||
duration,
|
||||
easing: quintOut,
|
||||
|
|
Loading…
Reference in New Issue