HTML5 Canvas Tween Finish Event Tutorial

Get last news, demos, posts from Konva

To trigger a user defined function when the tween finishes with Konva, we can set the onFinish property.

Konva Tween Finish Event Demoview raw
<!DOCTYPE html>
<script src="[email protected]/konva.min.js"></script>
<meta charset="utf-8" />
<title>Konva Finish Event Demo</title>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
<div id="container"></div>
function writeMessage(message) {

var width = window.innerWidth;
var height = window.innerHeight;

var stage = new Konva.Stage({
container: 'container',
width: width,
height: height

var layer = new Konva.Layer();

var text = new Konva.Text({
x: 10,
y: 10,
fontFamily: 'Calibri',
fontSize: 24,
text: '',
fill: 'black'

var wheel = new Konva.Star({
x: stage.width() / 2,
y: stage.height() / 2,
numPoints: 8,
outerRadius: 70,
innerRadius: 50,
fill: 'purple',
stroke: 'black',
strokeWidth: 5,
lineJoin: 'bevel'


// the tween has to be created after the node has been added to the layer
var tween = new Konva.Tween({
node: wheel,
duration: 4,
rotation: 360,
easing: Konva.Easings.BackEaseOut,
onFinish: function() {
writeMessage('tween finished!');

setTimeout(function() {;
}, 1000);