mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-23 03:56:23 +00:00
16 lines
534 B
JavaScript
16 lines
534 B
JavaScript
import { router, navigate, reload, prefetch } from "https://unpkg.com/million@1.9.5/dist/router.mjs"
|
|
|
|
export const attachSPARouting = (draw) => {
|
|
// Attach SPA functions to the global Million namespace
|
|
window.Million = {
|
|
router,
|
|
navigate,
|
|
reload,
|
|
prefetch,
|
|
};
|
|
router(".singlePage")
|
|
// We need on initial load, then subsequent redirs
|
|
// requestAnimationFrame() delays graph draw until SPA routing is finished
|
|
reload(draw)
|
|
window.addEventListener("DOMContentLoaded", () => requestAnimationFrame(draw))
|
|
}
|