Using Animated GIF in GoJS Picture Object

Hello. We have been trying to load animated GIFs into the go.Picture() object and we can load the image, but it does not animate. Is there something special that we need to set to get GIF to animate?

GoJS doesn’t handle indefinite animation for performance reasons, but you can kinda force it to by calling myDiagram.redraw() in a loop.

For performance reasons, you may not want to do this unless you really want that behavior.

setInterval(function() {
  myDiagram.redraw();
}, 100);

Calling redraw() during animation frames is how the WebGL node animates in this demo, by the way: Various Charts in GoJS Nodes

Simon. I put my setInterval function call in and it is firing, but my GIF is still not animating. Is there something else that I need to do with the go.Picture object that contains the animated GIF.

Oh I’m sorry, it seems I was mistaken. The HTML Canvas specification doesn’t allow you to display .gif animations, it won’t increase their frame. So you cannot easily use gifs in GoJS because you cannot easily use gifs in HTML Canvas.

You could write some code to loop through several different image frames, like a sprite sheet, but I’d recommend against this if you can live without the animation.

Thanks. This is good information. I will take this back to my development team.