___ _ ___ ___ _ | _ (_)__ ___/ __| _ \/_\ | _/ / _/ _ \__ \ _/ _ \ |_| |_\__\___/___/_|/_/ \_\ A PicoSSG tool

picospa.scroll

API for storing and restoring scroll positions across page loads for both window and specific scrollable elements.

restore()

Method signature: restore({key?: string, otherNodes? = []})

Stores current scroll positions before page unload and restores them on page load.

Parameters

Description

The function sets up two main behaviors:

Storage (on beforeunload)

Restoration (immediate)

DOM Requirements

Storage Details

Example

// Basic usage - window scroll only
picospa.scroll.restore({key: 'my-page'});

// With additional scrollable elements
picospa.scroll.restore({key: 'docs-page', otherNodes: [
  '#sidebar',
  '.content-area',
  '[data-scrollable="true"]'
]});

// Cross-page state with same key
picospa.scroll.restore({key: 'shared-layout', otherNodes: ['#navigation']});

Error Handling

Browser Events

Performance Notes