hyesungoh / comet-land

Blog and Resume template :comet:

Home Page:https://comet-land-blog.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scroll Restoration

hyesungoh opened this issue · comments

Description

index에서 scroll 후 [slug] 방문 시 store restoration되지 않음

시도한 방법

Route.events

route를 벗어날 때 스크롤 좌표를 caching한 후, 돌아왔을 때 캐싱된 값만큼 scroll

+기존 구조를 바꾸지 않아도 쉽게 적용 가능함
-일반 `window.scrollTo`를 사용할 시 `race condition` 이슈로 dom 변경이 block되어,  setTimeout을 이용하여 적용해야 동작함
-하지만 infinite scroll된 값까지 적용되진 않음

Route as Modal

+infinite scroll된 스크롤까지 적용
-위 구현방법보다 구조를 많이 바꿔야 함
-SSG이기 때문에 index route와 slug route 모두 생성하여 빌드시간이 n에서 n^2으로 늘어남

Next.config.js

해당 이슈를 참고하였으나 작동하지 않음.

infinite scroll된 값까지 적용된다면 가장 적절한 해결방법같아 보이지만, 추가적인 시도를 해봐야할 것으로 판단