JSFiddle - React, Tailwind, and code Playground
by Eskel
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]/konva.min.js"></script>
<meta charset="utf-8" />
<title>Konva Pointer Events Demo</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
function writeMessage(message) {
text.text(message);
}
var stage = new Konva.Stage({
container: 'container',
width: window.innerWidth,
height: window.innerHeight,
});
var layer = new Konva.Layer();
var text = new Konva.Text({
x: 10,
y: 10,
fontFamily: 'Calibri',
fontSize: 24,
text: '',
fill: 'black',
});
stage.on('pointermove', function () {
var pointerPos = stage.getPointerPosition();
var x = pointerPos.x - 190;
var y = pointerPos.y - 40;
writeMessage('x: ' + x + ', y: ' + y);
});
stage.on('pointerdown', function () {
writeMessage('pointerdown circle');
});
stage.on('pointerup', function () {
writeMessage('pointerup circle');
});
layer.add(text);
// add the layer to the stage
stage.add(layer);
</script>
</body>
</html>