Skip to content

Commit

Permalink
fix: cancels the startScrollDamping internal call to window
Browse files Browse the repository at this point in the history
  • Loading branch information
WRXinYue committed Sep 20, 2024
1 parent aa967e8 commit a4328d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion theme/setup/sakuraSetup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useWindowSize } from '@vueuse/core'
import type { ThemeConfig } from '../types'
import { startScrollDamping } from '../utils/scrollDamping'
import { useSakuraAppStore } from '../stores'
Expand All @@ -6,8 +7,9 @@ import { StorageKeys } from '../enum'

export function defineSakuraSetup(themeConfig: ThemeConfig) {
const sakuraAppStore = useSakuraAppStore()
const { width } = useWindowSize()

if (themeConfig.scrollDamping)
if (themeConfig.scrollDamping && width.value >= 768)
startScrollDamping()

// SidebarOptions
Expand Down
10 changes: 4 additions & 6 deletions theme/utils/scrollDamping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ function raf(time: any) {
}

export async function startScrollDamping() {
if (window.innerWidth >= 768) {
const LenisModule = await import('@studio-freight/lenis')
const Lenis = LenisModule.default
lenis = new Lenis({ lerp: 0.04 })
const LenisModule = await import('@studio-freight/lenis')
const Lenis = LenisModule.default
lenis = new Lenis({ lerp: 0.04 })

requestAnimationFrame(raf)
}
requestAnimationFrame(raf)
}

export function scrollToTop() {
Expand Down

0 comments on commit a4328d3

Please sign in to comment.