From f9285e2a5a7042b99a9fd079a788ffb9013dd751 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 6 Aug 2024 22:42:35 +0800 Subject: [PATCH] chore: animated scrollbar Signed-off-by: Innei --- package.json | 2 +- pnpm-lock.yaml | 6 +++--- src/renderer/src/components/ui/scroll-area/ScrollArea.tsx | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8b548da95..2ae0446a7 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,6 @@ "sonner": "^1.5.0", "swiper": "11.1.8", "tailwind-merge": "2.4.0", - "tailwindcss-animate": "1.0.7", "tldts": "6.1.35", "unified": "11.0.5", "usehooks-ts": "3.1.0", @@ -165,6 +164,7 @@ "rollup-plugin-visualizer": "5.12.0", "simple-git-hooks": "2.11.1", "tailwindcss": "3.4.7", + "tailwindcss-animate": "1.0.7", "typescript": "^5.5.4", "vite": "^5.3.4", "vite-plugin-mkcert": "1.17.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f6a15c5b..a3daea229 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -283,9 +283,6 @@ importers: tailwind-merge: specifier: 2.4.0 version: 2.4.0 - tailwindcss-animate: - specifier: 1.0.7 - version: 1.0.7(tailwindcss@3.4.7) tldts: specifier: 6.1.35 version: 6.1.35 @@ -419,6 +416,9 @@ importers: tailwindcss: specifier: 3.4.7 version: 3.4.7 + tailwindcss-animate: + specifier: 1.0.7 + version: 1.0.7(tailwindcss@3.4.7) typescript: specifier: ^5.5.4 version: 5.5.4 diff --git a/src/renderer/src/components/ui/scroll-area/ScrollArea.tsx b/src/renderer/src/components/ui/scroll-area/ScrollArea.tsx index 230916d97..2d131109c 100644 --- a/src/renderer/src/components/ui/scroll-area/ScrollArea.tsx +++ b/src/renderer/src/components/ui/scroll-area/ScrollArea.tsx @@ -36,6 +36,7 @@ const Thumb = React.forwardRef< "dark:bg-neutral-500 hover:dark:bg-neutral-400/80 active:dark:bg-neutral-400", "before:absolute before:-left-1/2 before:-top-1/2 before:h-full before:min-h-[44]", "before:w-full before:min-w-[44] before:-translate-x-full before:-translate-y-full before:content-[\"\"]", + className, )} /> @@ -56,6 +57,7 @@ export const Scrollbar = React.forwardRef< orientation === "horizontal" ? `h-2.5 w-full flex-col` : `w-2.5 flex-row`, + "animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in", className, )} > @@ -84,7 +86,7 @@ export const Viewport = React.forwardRef< if (!$el) return if (!$child) return const handler = () => { - setShouldAddMask($el.scrollHeight > ($el.clientHeight + 48 * 2)) + setShouldAddMask($el.scrollHeight > $el.clientHeight + 48 * 2) } const observer = new ResizeObserver(handler) handler()