mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: updates
This commit is contained in:
parent
a1b0bcf4d3
commit
884f3df41a
198 changed files with 4572 additions and 5336 deletions
20
packages/web/components/ScrollRestoration.tsx
Normal file
20
packages/web/components/ScrollRestoration.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useLayoutEffect } from 'react'
|
||||
import scrollPositions from '@/web/states/scrollPositions'
|
||||
import { throttle } from 'lodash-es'
|
||||
|
||||
const ScrollRestoration = () => {
|
||||
useLayoutEffect(() => {
|
||||
const main = document.querySelector('main')
|
||||
const handleScroll = throttle(() => {
|
||||
scrollPositions.set(window.location.pathname, main?.scrollTop ?? 0)
|
||||
}, 200)
|
||||
main?.addEventListener('scroll', handleScroll)
|
||||
return () => {
|
||||
main?.removeEventListener('scroll', handleScroll)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
export default ScrollRestoration
|
||||
Loading…
Add table
Add a link
Reference in a new issue