1
0
mirror of https://github.com/konvajs/konva.git synced 2025-04-05 20:48:28 +08:00

fix pointer events

This commit is contained in:
Anton Lavrenov 2021-10-22 10:09:34 -05:00
parent a6bbbff406
commit 272627a2da
4 changed files with 52 additions and 6 deletions

View File

@ -3,6 +3,8 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
###
## 8.2.2
- Fix `Konva.Arrow` rendering when it has two pointers

View File

@ -22,7 +22,7 @@
"test:build": "parcel build ./test/unit-tests.html --dist-dir test-build --target none --public-url ./ --no-source-maps",
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security",
"test:node": "env TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha -r ts-node/register test/unit/**/*.ts --exit && npm run test:import",
"test:watch": "rm -rf ./parcel-cache && parcel serve ./test/unit-tests.html ./test/manual-tests.html",
"test:watch": "rm -rf ./parcel-cache && parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html",
"tsc": "tsc --removeComments && tsc --build ./tsconfig-cmj.json",
"rollup": "rollup -c",
"clean": "rm -rf ./lib && rm -rf ./types && rm -rf ./cmj && rm -rf ./test-build",

View File

@ -965,8 +965,8 @@ export const Util = {
},
_getFirstPointerId(evt) {
if (!evt.touches) {
// fake id for mouse
return 999;
// try to use pointer id or fake id
return evt.pointerId || 999;
} else {
return evt.changedTouches[0].identifier;
}

View File

@ -22,9 +22,53 @@
</head>
<body>
Some text
<div id="container"></div>
<script src="../src/index.ts" type="module"></script>
<script></script>
<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>