list-scroll-cache.ts 443 B

12345678910111213141516
  1. const scrollOffsetCache = new Map()
  2. /** Scroll restore is view state, not page data — independent of cache flags. */
  3. export function getListScrollOffset(url: string) {
  4. if (!url) return 0
  5. return scrollOffsetCache.get(url) ?? 0
  6. }
  7. export function setListScrollOffset(url: string, offset: number) {
  8. if (!url) return
  9. scrollOffsetCache.set(url, offset)
  10. }
  11. export function clearListScrollCache() {
  12. scrollOffsetCache.clear()
  13. }