mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
Add retry RAF
This commit is contained in:
parent
d703cd8c0e
commit
e82f2bb5d0
@ -1,8 +1,5 @@
|
||||
async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLegend, enableZoom) {
|
||||
const container = document.getElementById("graph-container");
|
||||
// We should clear the graph in case there is anything within it
|
||||
if (!container) return;
|
||||
container.textContent = "";
|
||||
|
||||
const { index, links, content } = await fetchData;
|
||||
const curPage = url.replace(baseUrl, "");
|
||||
|
||||
@ -51,8 +51,13 @@
|
||||
window.navigate = navigate;
|
||||
router(".singlePage");
|
||||
const callback = () => {
|
||||
// RAF waits for Million to complete diffing, then draw
|
||||
requestAnimationFrame(() => {
|
||||
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 = "";
|
||||
|
||||
drawGraph(
|
||||
{{strings.TrimRight "/" .Page.Permalink}},
|
||||
{{strings.TrimRight "/" .Site.BaseURL}},
|
||||
@ -61,9 +66,10 @@
|
||||
{{$.Site.Data.graphConfig.enableDrag}},
|
||||
{{$.Site.Data.graphConfig.enableLegend}},
|
||||
{{$.Site.Data.graphConfig.enableZoom}}
|
||||
)}
|
||||
);
|
||||
};
|
||||
requestAnimationFrame(draw);
|
||||
};
|
||||
// We need on initial load, then subsequent redirs
|
||||
window.addEventListener("million:navigate", callback);
|
||||
window.addEventListener("DOMContentLoaded", callback);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user