mirror of
https://github.com/falsycat/ar.falsy.cat.git
synced 2024-11-12 23:04:52 +00:00
27 lines
551 B
JavaScript
27 lines
551 B
JavaScript
import {
|
|
apply,
|
|
navigate,
|
|
prefetch,
|
|
router,
|
|
} from "https://unpkg.com/million@1.11.3/dist/router.mjs"
|
|
|
|
export const attachSPARouting = (init, rerender) => {
|
|
// Attach SPA functions to the global Million namespace
|
|
window.Million = {
|
|
apply,
|
|
navigate,
|
|
prefetch,
|
|
router,
|
|
}
|
|
|
|
const render = () => requestAnimationFrame(rerender)
|
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
|
apply((doc) => init(doc))
|
|
init()
|
|
router(".singlePage")
|
|
render()
|
|
})
|
|
window.addEventListener("million:navigate", render)
|
|
}
|