___ ___ _____ _ ( _`\ ( _`\ ( _ ) _ ( ) | (_(_)| |_) )| (_) |(_) ___ | |__ `\__ \ | ,__/'| _ || |/',__)| _ `\ ( )_) || | | | | || |\__, \| | | | `\____)(_) (_) (_)(_)(____/(_) (_) A PicoSSG tool

Scroll

SPAish allows you to store and restore scroll positions across page loads, maintaining the user's scroll position in both the window and specific scrollable elements.

Try it Out

1️⃣ Try first

2️⃣ Try second

3️⃣ Try this too:

How To Use

Add the script to your page and call restore with a unique page key:

<script src="https://cdn.jsdelivr.net/npm/@wolframkriesing/spaish@1.0.5/_dist/spaish.min.js"></script>
<script>
  spaish.scroll.restore('my-page-key');
</script>

This will:

Scrollable Elements

You can also restore scroll positions for specific scrollable elements:

spaish.scroll.restore('my-page-key', [
  '#sidebar',
  '.content-area',
  '[data-scrollable]'
]);

Both window and element scroll positions will be preserved.

Storage

Scroll positions are stored in sessionStorage using the provided page key:

Important Notes