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.

27 lines
552 B
JavaScript

3 years ago
import {
apply,
navigate,
prefetch,
router,
} from "https://unpkg.com/million@1.9.8-0/dist/router.mjs"
3 years ago
3 years ago
export const attachSPARouting = (init, rerender) => {
// Attach SPA functions to the global Million namespace
window.Million = {
3 years ago
apply,
navigate,
prefetch,
3 years ago
router,
}
const render = () => requestAnimationFrame(rerender)
window.addEventListener("DOMContentLoaded", () => {
apply((doc) => init(doc))
init()
router(".singlePage")
render()
})
window.addEventListener("million:navigate", render)
3 years ago
}