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