mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
75 lines
2.0 KiB
HTML
75 lines
2.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>KonvaJS Sandbox</title>
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0"
|
|
/>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
}
|
|
</style>
|
|
<!-- <script src="https://cdn.rawgit.com/hammerjs/touchemulator/master/touch-emulator.js"></script> -->
|
|
<script>
|
|
// TouchEmulator();
|
|
</script>
|
|
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.7/hammer.js"></script> -->
|
|
<!-- <script src="https://cdn.rawgit.com/hammerjs/touchemulator/master/touch-emulator.js"></script> -->
|
|
<!-- <script src="./hammer.js"></script> -->
|
|
</head>
|
|
|
|
<body>
|
|
<div id="container"></div>
|
|
<script type="module">
|
|
import Konva from '../src/index.ts';
|
|
const stage = new Konva.Stage({
|
|
container: 'container',
|
|
width: window.innerWidth,
|
|
height: window.innerHeight,
|
|
});
|
|
|
|
const layer = new Konva.Layer();
|
|
stage.add(layer);
|
|
|
|
for (var i = 0; i < 1; i++) {
|
|
const group = new Konva.Group();
|
|
layer.add(group);
|
|
for (var j = 0; j < 1; j++) {
|
|
const shape = new Konva.Circle({
|
|
x: stage.width() / 2,
|
|
y: stage.height() / 2,
|
|
radius: 50,
|
|
fill: 'green',
|
|
});
|
|
group.add(shape);
|
|
}
|
|
}
|
|
|
|
stage.on('click', () => {
|
|
console.time('rect');
|
|
for (var i = 0; i < 50; i++) {
|
|
stage.getClientRect();
|
|
}
|
|
console.timeEnd('rect');
|
|
console.log('click');
|
|
});
|
|
|
|
// document.querySelector('canvas').addEventListener('pointerdown', (e) => {
|
|
// e.target.setPointerCapture(e.pointerId);
|
|
// });
|
|
|
|
stage.on('pointerup', () => {
|
|
console.log('stage pointer up');
|
|
});
|
|
window.onpointerup = () => {
|
|
console.log('window pointer up');
|
|
};
|
|
|
|
window.stage = stage;
|
|
</script>
|
|
</body>
|
|
</html>
|