HTML5 Canvas Batch Draw Tip

In some situations, we may want to update a Konva shape as fast as possible,
but without causing too many redraws. For example, if we want to update an
element on the stage via mousemove, we don’t want to redraw the layer with the
draw() method, because the mousemove event could be fired hundreds of times per
second, which would result in a forced frame rate of over a hundred frames per second.
Often times this can cause jumpy animations because browsers simply can’t handle excessive redraws.

For situations like this, it’s much better to use the batchDraw() method
which automatically hooks redraws into the Konva animation engine.
No matter how many times you call batchDraw(), Konva will automatically
limit the number of redraws per second based on the maximum number of frames
per second that the browser can handle at any given point in time.

Instructions: Move your mouse over the stage to spin the rectangle

Konva Batch Draw Demoview raw
<!DOCTYPE html>
<script src=""></script>
<meta charset="utf-8">
<title>Konva Batch Draw Demo</title>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #F0F0F0;
<div id="container"></div>
var stage = new Konva.Stage({
container: 'container',
width: 300,
height: 250
var layer = new Konva.Layer();
var rect = new Konva.Rect({
x: 110,
y: 100,
width: 200,
height: 20,
offset: {
x : 100,
y : 10
fill: 'green',
stroke: 'black',
strokeWidth: 4
// add the shape to the layer
// add the layer to the stage
stage.on('contentMousemove', function() {