mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 05:14:06 -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) {
|
async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLegend, enableZoom) {
|
||||||
const container = document.getElementById("graph-container");
|
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 { index, links, content } = await fetchData;
|
||||||
const curPage = url.replace(baseUrl, "");
|
const curPage = url.replace(baseUrl, "");
|
||||||
|
|||||||
@ -51,8 +51,13 @@
|
|||||||
window.navigate = navigate;
|
window.navigate = navigate;
|
||||||
router(".singlePage");
|
router(".singlePage");
|
||||||
const callback = () => {
|
const callback = () => {
|
||||||
// RAF waits for Million to complete diffing, then draw
|
const draw = () => {
|
||||||
requestAnimationFrame(() => {
|
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(
|
drawGraph(
|
||||||
{{strings.TrimRight "/" .Page.Permalink}},
|
{{strings.TrimRight "/" .Page.Permalink}},
|
||||||
{{strings.TrimRight "/" .Site.BaseURL}},
|
{{strings.TrimRight "/" .Site.BaseURL}},
|
||||||
@ -61,8 +66,9 @@
|
|||||||
{{$.Site.Data.graphConfig.enableDrag}},
|
{{$.Site.Data.graphConfig.enableDrag}},
|
||||||
{{$.Site.Data.graphConfig.enableLegend}},
|
{{$.Site.Data.graphConfig.enableLegend}},
|
||||||
{{$.Site.Data.graphConfig.enableZoom}}
|
{{$.Site.Data.graphConfig.enableZoom}}
|
||||||
)}
|
);
|
||||||
);
|
};
|
||||||
|
requestAnimationFrame(draw);
|
||||||
};
|
};
|
||||||
// We need on initial load, then subsequent redirs
|
// We need on initial load, then subsequent redirs
|
||||||
window.addEventListener("million:navigate", callback);
|
window.addEventListener("million:navigate", callback);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user