How to detect when an OMSVGImageElement has finished loading

7 views
Skip to first unread message

Arturs Elksnis

unread,
Dec 6, 2018, 11:32:28 AM12/6/18
to lib-gwt-svg
Hi,
    I am using "OMSVGImageElement" objects in my GWT application running on Google Chrome. So basically I create them dynamically like this :

[CODE]
private static final OMSVGDocument doc = OMSVGParser.currentDocument();
private final OMSVGSVGElement mSVGElement;

image
= doc.createSVGImageElement((float) x1, (float) y1, (float) (x2 - x1), (float) (y2 - y1), "");

image
.getHref().setBaseVal(href);

mSVGElement.appendChild(image);


[/CODE]

Where "href" can either be hex data for my image (starting with "data:image") or a URL (starting with "http://").

After that I send the page, where "mSVGElement" resides, to printing dialogue, which gives me a print preview. Now I noticed that sometimes some of the images got missing. So I added a LoadHandler:

image.addLoadHandler(new LoadHandler()
{
@Override
public void onLoad(LoadEvent event)
{
                                /**
                                 * If all images have loaded, then print
                                 */
doBehaviourIfConditionsAreRight();
}
});


Now those pictures that I load from a URL, work fine-- they are always there and don't go missing anymore. But those pictures, which I set from hex data, do go missing- and even more, than before.

So I guess my question is: What can I do to track their loading and guarantee that I print the page AFTER they have loaded? Is there another event that I can monitor with another handler (similarly to how I did it with LoadHandler)? Is there any other way, because LoadHandler doesn't work for me, even though it gets triggered by the hex-loaded images.

Please let me know if you need any more details.

Thanks,
Arturs
Reply all
Reply to author
Forward
0 new messages