You can’t directly insert GIF image into the canvas. But we can use external library to parse the gif and then we can draw it into the layer as Konva.Image shape.
In this demo I will use gifler to parse and draw the gif. You can use any other library.
<body> <divid="container"></div> <script> var width = window.innerWidth; var height = window.innerHeight;
var stage = new Konva.Stage({ container: 'container', width: width, height: height });
var layer = new Konva.Layer(); stage.add(layer);
var canvas = document.createElement('canvas'); // use external library to parse and draw gif animation functiononDrawFrame(ctx, frame){ // update canvas size canvas.width = frame.width; canvas.height = frame.height; // update canvas that we are using for Konva.Image ctx.drawImage(frame.buffer, 0, 0); // redraw the layer layer.draw(); }