Fix popover
parent
6e6dd4cb0b
commit
77485b754d
@ -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)
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
{{if $.Site.Data.config.enableLinkPreview}}
|
||||
{{ $js := resources.Get "js/popover.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||
<script src="{{ $js.Permalink }}"></script>
|
||||
<script>
|
||||
initPopover({{strings.TrimRight "/" .Site.BaseURL }})
|
||||
</script>
|
||||
{{end}}
|
Loading…
Reference in New Issue