When importing the ghostscript tiger in javascript, no value is returned from project.importSVG. The graphic is displayed correctly.
Expected behavior:
importSVG returns a reference to the Item containing the SVG.
Current behavior:
importSVG returns undefined.
paper.setup(document.getElementById("paper_canvas"));
var svg = paper.project.importSVG("img/ghostscript_tiger.svg");
console.log(svg); // => undefined
You need to use an onload callback function to know when the file is loaded:
paper.project.importSVG("img/ghostscript_tiger.svg", function(item) {
console.log(item);
});
Thanks!
The documentation doesn't mention callback functions (and I was a bit surprised that the docs suggested it would be a blocking call in js). Is there somewhere I can contribute to the documentation?
Yeah that feature was added later. Hard to keep it all in sync...
Most helpful comment
You need to use an onload callback function to know when the file is loaded: