DocsMenus & navigation
Get started

Search Subtly documentation

Search by a task, helper name or framework.

Menus & navigation

navigationMemory()

Restore a list and its scroll position.

Try the example

Scroll the project list and save your position. Scroll somewhere else, then restore. The saved position is held in memory for this page only.

Project 01Design review
Project 02Design review
Project 03Design review
Project 04Design review
Project 05Design review
Project 06Design review
Project 07Design review
Project 08Design review
Project 09Design review
Project 10Design review
Project 11Design review
Project 12Design review
Project 13Design review
Project 14Design review
Project 15Design review

Scroll the list to begin.

Actual npm package · local demonstration

Add it to your project

  1. Copy the HTML. Place the markup inside the component where this behavior belongs. The preview’s visual classes are website styles; use your own design system.
  2. Connect the behavior. Copy the JavaScript tab and call its exported mount(element) after your component’s elements exist. Replace simulated delays and data operations with your own application code.
  3. Clean up. Call the returned cleanup when the component unmounts. It aborts the example’s listeners and releases the helper’s timers, observers or state.

API and lifecycle

Create a memory instance and save(key, list, state) before leaving a list. It stores scroll coordinates plus a cloned state object; read(key) returns that state. Use keys that identify the route and list.

Interface
max; save/read/restore/clear
Lifecycle
Restore filters and render the list before calling restore(key, list). It returns whether a saved entry exists. clear() removes all entries; storage is memory-only, with 30 entries by default.

Accessibility and safety

Implementation notes

Initialize after the DOM is available. Keep native controls and keyboard interactions intact; release listeners and timers on unmount.

Restore a useful position without stealing focus. Avoid sharing an instance across user sessions or storing sensitive filter values unnecessarily.

What to check

Scroll and filter a list, visit a detail view and return. Confirm state is restored after rendering and that missing entries are handled normally.