You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
534 B
JavaScript

3 years ago
import { router, navigate, reload, prefetch } from "https://unpkg.com/million@1.9.6/dist/router.mjs"
3 years ago
export const attachSPARouting = (draw) => {
// Attach SPA functions to the global Million namespace
window.Million = {
router,
navigate,
reload,
prefetch,
};
3 years ago
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))
3 years ago
}