feat: 初始化Arctic New One项目基础架构
添加项目基础文件结构,包括: - 国际化多语言支持 - Tailwind CSS配置 - 自定义布局组件 - 平滑滚动和动画效果 - 自定义光标交互 - 错误页面处理
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import Lenis from 'lenis'
|
||||
import 'lenis/dist/lenis.css'
|
||||
import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
// 用 Lenis 平滑浏览器原始 wheel 输入,避免鼠标滚轮一格跳太远。
|
||||
const lenis = new Lenis({
|
||||
lerp: 0.075,
|
||||
wheelMultiplier: 0.7,
|
||||
})
|
||||
|
||||
const updateLenis = (time: number) => {
|
||||
lenis.raf(time * 1000)
|
||||
}
|
||||
|
||||
// ScrollTrigger 必须跟随 Lenis 的平滑滚动值更新,否则触发点会和真实视觉滚动不同步。
|
||||
lenis.on('scroll', ScrollTrigger.update)
|
||||
gsap.ticker.add(updateLenis)
|
||||
gsap.ticker.lagSmoothing(0)
|
||||
|
||||
// Nuxt 卸载时清掉 ticker 和事件,避免热更新或页面销毁后重复驱动滚动。
|
||||
nuxtApp.hook('app:beforeUnmount', () => {
|
||||
lenis.off('scroll', ScrollTrigger.update)
|
||||
gsap.ticker.remove(updateLenis)
|
||||
lenis.destroy()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user