mirror of
https://github.com/alrayyes/wiki.git
synced 2025-06-20 03:56:34 +00:00
Fix popover
This commit is contained in:
parent
6e6dd4cb0b
commit
77485b754d
9 changed files with 67 additions and 64 deletions
assets/js
25
assets/js/router.js
Normal file
25
assets/js/router.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { router, navigate } from "https://unpkg.com/million/dist/router.mjs"
|
||||
|
||||
export const init = (loader) => {
|
||||
// SPA navigation for access later
|
||||
window.navigate = navigate
|
||||
// We only mutate document.title and content within .singlePage element
|
||||
router(".singlePage")
|
||||
// We need on initial load, then subsequent redirs
|
||||
window.addEventListener("million:navigate", () => callback(loader))
|
||||
window.addEventListener("DOMContentLoaded", () => callback(loader))
|
||||
}
|
||||
|
||||
export const callback = (loader) => {
|
||||
// requestAnimationFrame() delays graph draw until SPA routing is finished
|
||||
const draw = () => {
|
||||
const container = document.getElementById("graph-container")
|
||||
// retry if the graph is not ready
|
||||
if (!container) return requestAnimationFrame(draw)
|
||||
// clear the graph in case there is anything within it
|
||||
container.textContent = ""
|
||||
|
||||
loader()
|
||||
}
|
||||
requestAnimationFrame(draw)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue