configure what mouse buttons can be used for drag&drop

This commit is contained in:
Anton Lavrenov
2019-02-14 10:33:58 -05:00
parent dcff79eb63
commit 1dea3696a2
8 changed files with 60 additions and 26 deletions

View File

@@ -2161,18 +2161,15 @@ export abstract class Node {
}
_listenDrag() {
var that = this;
this._dragCleanup();
this.on('mousedown.konva touchstart.konva', function(evt) {
// ignore right and middle buttons
// TODO: should we add a global config for buttons?
if (evt.evt.button === 1 || evt.evt.button === 2) {
var canDrag = getGlobalKonva().dragButtons.indexOf(evt.evt.button) >= 0;
if (!canDrag) {
return;
}
if (!DD.node) {
that.startDrag();
this.startDrag();
}
});
}

View File

@@ -21,11 +21,6 @@ function getDummyContext() {
return dummyContext;
}
// TODO: write a test for adding destroyed shape into the layer
// will it draw?
// will it pass hit test?
// show warning on adding destroyed shape?
// TODO: idea - use only "remove" (or destroy method)
// how? on add, check that every inner shape has reference in konva store with color
// on remove - clear that reference

View File

@@ -65,6 +65,18 @@ export const angleDeg = true;
*/
export const showWarnings = true;
/**
* Configure what mouse buttons can be used for drag and drop.
* Default value is [0] - only left mouse button.
* @property dragButtons
* @default true
* @memberof Konva
* @example
* // enable left and right mouse buttons
* Konva.dragButtons = [0, 2];
*/
export const dragButtons = [0, 1];
// export default KonvaInternals;
// shapes