Skip to content

Commit

Permalink
Robust wait until Viz is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jbussemaker committed Jan 29, 2024
1 parent abf7c46 commit d593832
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions adsg_core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ def _wrap_html(dot):
function doRender() {{
Viz.instance().then(function(viz) {{ document.getElementById("{div_id}").appendChild(viz.renderSVGElement(dot)); }});
}}
// We need to wait for loading to complete
if (typeof Viz === "undefined") {{ setTimeout(doRender, 200); }} else {{ doRender(); }}
// We may need to wait for loading to complete
function checkRender() {{
if (typeof Viz === "undefined") {{ setTimeout(checkRender, 200); }} else {{ doRender(); }}
}}
checkRender();
}})()
</script>
"""
Expand Down

0 comments on commit d593832

Please sign in to comment.