2022-05-27 16:49:28 +00:00
|
|
|
import { router, navigate, reload, prefetch } from "https://unpkg.com/million@1.9.4/dist/router.mjs"
|
2022-05-03 15:47:42 +00:00
|
|
|
|
2022-05-03 17:16:09 +00:00
|
|
|
export const attachSPARouting = (draw) => {
|
2022-05-27 15:39:44 +00:00
|
|
|
// Attach SPA functions to the global Million namespace
|
|
|
|
window.Million = {
|
|
|
|
router,
|
|
|
|
navigate,
|
|
|
|
reload,
|
|
|
|
prefetch,
|
|
|
|
};
|
2022-05-03 15:47:42 +00:00
|
|
|
router(".singlePage")
|
|
|
|
// We need on initial load, then subsequent redirs
|
|
|
|
// requestAnimationFrame() delays graph draw until SPA routing is finished
|
2022-05-27 15:39:44 +00:00
|
|
|
reload(draw)
|
2022-05-03 17:16:09 +00:00
|
|
|
window.addEventListener("DOMContentLoaded", () => requestAnimationFrame(draw))
|
2022-05-03 15:47:42 +00:00
|
|
|
}
|