@pdehne/mithril-scroll-restoration

0.1.3 • Public • Published

mithril-scroll-restoration

Scroll restoration for MithrilJS.

Integration

Install the npm package:

$ npm install @pdehne/mithril-scroll-restoration

In your top level JavaScript file import mithril-scroll-restoration and initialize it:

import { initScrollRestoration, ScrollRestoration } from "@pdehne/mithril-scroll-restoration";
...
initScrollRestoration(m);
m.route(document.body, "/", Routes);

Wrap your top level component in the provided ScrollRestoration component, for example:

const Layout = {
  view: vnode => m(ScrollRestoration, [
      m(NavBar),
      vnode.children,
      m(Footer)
  ])
}

Example

See example.html / example.js / example.css for a working example. To run the example clone this repository, open a terminal, cd to the top level folder of the repository and run npm install followed by npm start.

Package Sidebar

Install

npm i @pdehne/mithril-scroll-restoration

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

8.52 kB

Total Files

9

Last publish

Collaborators

  • pdehne