Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/DragAndDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,20 @@ export const DD = {
}
});
},
};
_attachListeners: function (targetWindow: Window) {
targetWindow.addEventListener('mouseup', DD._endDragBefore, true);
targetWindow.addEventListener('touchend', DD._endDragBefore, true);
targetWindow.addEventListener('touchcancel', DD._endDragBefore, true);

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);
targetWindow.addEventListener('mousemove', DD._drag);
targetWindow.addEventListener('touchmove', DD._drag);

window.addEventListener('mousemove', DD._drag);
window.addEventListener('touchmove', DD._drag);
targetWindow.addEventListener('mouseup', DD._endDragAfter, false);
targetWindow.addEventListener('touchend', DD._endDragAfter, false);
targetWindow.addEventListener('touchcancel', DD._endDragAfter, false);
},
};

window.addEventListener('mouseup', DD._endDragAfter, false);
window.addEventListener('touchend', DD._endDragAfter, false);
window.addEventListener('touchcancel', DD._endDragAfter, false);
if (Konva.isBrowser) {
DD._attachListeners(window);
}
6 changes: 6 additions & 0 deletions src/Stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ export class Stage extends Container<Layer, StageConfig> {
}
return this;
}
setWindow(win){
if (win) {
DD._attachListeners(win);
}
return this;
}
shouldDrawHit() {
return true;
}
Expand Down