fix freeze on ios. close #1843

This commit is contained in:
lavrton 2024-10-21 18:11:22 -05:00
parent e9b8d84144
commit 5cdde09fb5
3 changed files with 17 additions and 15 deletions

View File

@ -20,7 +20,7 @@
"test": "npm run test:browser && npm run test:node",
"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:watch": "rm -rf ./.parcel-cache && parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
"test:watch": "rm -rf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
"test:node": "ts-mocha -r ./test/node-global-setup.mjs -p ./test/tsconfig.json test/unit/**/*.ts --exit && npm run test:import",
"tsc": "tsc --removeComments",
"rollup": "rollup -c --bundleConfigAsCjs",

View File

@ -161,10 +161,13 @@ export const DD = {
if (Konva.isBrowser) {
window.addEventListener('mouseup', DD._endDragBefore, true);
window.addEventListener('touchend', DD._endDragBefore, true);
// add touchcancel to fix this: https://github.com/konvajs/konva/issues/1843
window.addEventListener('touchcancel', DD._endDragBefore, true);
window.addEventListener('mousemove', DD._drag);
window.addEventListener('touchmove', DD._drag);
window.addEventListener('mouseup', DD._endDragAfter, false);
window.addEventListener('touchend', DD._endDragAfter, false);
window.addEventListener('touchcancel', DD._endDragAfter, false);
}

View File

@ -44,28 +44,27 @@
var layer = new Konva.Layer();
stage.add(layer);
var text = new Konva.Text({
var rect = new Konva.Rect({
x: 10,
y: 10,
text: 'Simple Text',
fontSize: 100,
fontFamily: 'Calibri',
width: 100,
height: 100,
fill: 'green',
textDecoration: 'underline line-through',
draggable: true,
});
layer.add(text);
layer.add(rect);
var tr = new Konva.Transformer({
nodes: [text],
window.addEventListener('touchend', () => {
console.log('touchend');
});
layer.add(tr);
tr.on('transformstart', () => {
console.log('transform start');
window.addEventListener('touchcancel', () => {
console.log('touchcancel');
});
tr.on('transformend', () => {
console.log('transform end');
window.addEventListener('lostpointercapture', () => {
console.log('lostpointercapture');
});
window.addEventListener('focusout', () => {
console.log('focusout');
});
</script>
</body>