From b0ab36f51b25b3c5757a58b29ce8b64bb1a745e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Nov 2025 16:54:02 +0000 Subject: [PATCH] Add Lenis smooth scrolling for improved interaction design - Integrate Lenis library for butter-smooth scrolling experience - Add scroll progress indicator bar at top of page - Create ScrollToTop button with gradient styling and animations - Implement scroll-linked CSS animations and reveal effects - Support Astro view transitions with proper lifecycle hooks - Add i18n support for scroll-to-top accessibility label --- package.json | 1 + src/components/core/LenisInit.astro | 170 ++++++++++++++++++++++++++++ src/components/ui/ScrollToTop.astro | 110 ++++++++++++++++++ src/i18n/languages.ts | 2 + src/layouts/BaseLayout.astro | 2 + src/layouts/PageLayout.astro | 2 + src/scripts/lenis-init.ts | 118 +++++++++++++++++++ 7 files changed, 405 insertions(+) create mode 100644 src/components/core/LenisInit.astro create mode 100644 src/components/ui/ScrollToTop.astro create mode 100644 src/scripts/lenis-init.ts diff --git a/package.json b/package.json index cf4c171..718ef23 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "astro": "^5.12.9", "cloudinary": "^2.8.0", "framer-motion": "^12.23.24", + "lenis": "^1.3.15", "limax": "^4.1.0", "lodash.merge": "^4.6.2", "matter-js": "^0.20.0", diff --git a/src/components/core/LenisInit.astro b/src/components/core/LenisInit.astro new file mode 100644 index 0000000..435915a --- /dev/null +++ b/src/components/core/LenisInit.astro @@ -0,0 +1,170 @@ +--- +/** + * Lenis Smooth Scrolling Component + * Initializes Lenis for butter-smooth scrolling experience + */ +--- + + + + + + diff --git a/src/components/ui/ScrollToTop.astro b/src/components/ui/ScrollToTop.astro new file mode 100644 index 0000000..765a17f --- /dev/null +++ b/src/components/ui/ScrollToTop.astro @@ -0,0 +1,110 @@ +--- +/** + * Scroll to Top Button + * A floating button that appears when user scrolls down and smoothly scrolls back to top + */ +--- + + + + + + + + + + diff --git a/src/i18n/languages.ts b/src/i18n/languages.ts index 17854a8..29df501 100644 --- a/src/i18n/languages.ts +++ b/src/i18n/languages.ts @@ -135,6 +135,7 @@ export const ui = { 'common.filter': '筛选', 'common.sort': '排序', 'common.all': '全部', + 'common.scrollToTop': '返回顶部', // 表单 'form.name': '姓名', @@ -753,6 +754,7 @@ export const ui = { 'common.filter': 'Filter', 'common.sort': 'Sort', 'common.all': 'All', + 'common.scrollToTop': 'Back to Top', // Form 'form.name': 'Name', diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 6bcf5c5..4e3494f 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -4,6 +4,7 @@ import '~/assets/styles/base.css'; import MetaTags from '~/components/core/MetaTags.astro'; import BasicScripts from '~/components/core/BasicScripts.astro'; import AOSInit from '~/components/core/AOSInit.astro'; +import LenisInit from '~/components/core/LenisInit.astro'; import { defaultLang } from '~/i18n/languages'; const { meta = {} } = Astro.props; @@ -19,6 +20,7 @@ const { meta = {} } = Astro.props; +