Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

How can I make sure that images are loaded before calling diagram.makeImage?

$
0
0

@cfarmerga wrote:

I have code that adds new nodes to my diagram and then creates a thumbnail image of the diagram. My nodes are in part made up of go.Pictures where the source property is bound to an svg file. I notice that sometimes after I add the node and the thumbnail image gets created, the thumbnail seems to have been generated before the svg picture has been rendered, so I have a hole in my thumbnail image. I have tried to pre-load the correct images from the server by

var img = new Image();
img.onload = image_loaded;
img.src = my_svg_url;

and wrapping those in promises to ensure that the thumbnail generation occurs after all the necessary images get loaded, but I still occasionally see a missing picture hole in my thumbnails. How can I guarantee that the images are loaded before I try to call makeImage?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles