mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
configure what mouse buttons can be used for drag&drop
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user