2022-05-30 10:40:44 +07:00
|
|
|
import {
|
|
|
|
apply,
|
|
|
|
navigate,
|
|
|
|
prefetch,
|
|
|
|
router,
|
2022-06-29 11:43:28 +07:00
|
|
|
} from "https://unpkg.com/million@1.11.3/dist/router.mjs"
|
2022-05-03 22:47:42 +07:00
|
|
|
|
2022-05-30 10:40:44 +07:00
|
|
|
export const attachSPARouting = (init, rerender) => {
|
2022-05-27 22:39:44 +07:00
|
|
|
// Attach SPA functions to the global Million namespace
|
|
|
|
window.Million = {
|
2022-05-30 10:40:44 +07:00
|
|
|
apply,
|
2022-05-27 22:39:44 +07:00
|
|
|
navigate,
|
|
|
|
prefetch,
|
2022-05-30 10:40:44 +07:00
|
|
|
router,
|
|
|
|
}
|
|
|
|
|
|
|
|
const render = () => requestAnimationFrame(rerender)
|
|
|
|
|
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
|
|
|
apply((doc) => init(doc))
|
|
|
|
init()
|
|
|
|
router(".singlePage")
|
|
|
|
render()
|
|
|
|
})
|
|
|
|
window.addEventListener("million:navigate", render)
|
2022-05-03 22:47:42 +07:00
|
|
|
}
|