mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
mouse dragging only with left button. fix #272
This commit is contained in:
parent
7412f76a39
commit
c34873d8c1
@ -185,7 +185,7 @@
|
|||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.isDragging = function() {
|
Kinetic.Node.prototype.isDragging = function() {
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
return dd.node && dd.node._id === this._id && dd.isDragging;
|
return !!(dd.node && dd.node._id === this._id && dd.isDragging);
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Node.prototype._listenDrag = function() {
|
Kinetic.Node.prototype._listenDrag = function() {
|
||||||
@ -202,6 +202,10 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.on('mousedown.kinetic touchstart.kinetic', function(evt) {
|
this.on('mousedown.kinetic touchstart.kinetic', function(evt) {
|
||||||
|
// ignore right and middle buttons
|
||||||
|
if (evt.evt.button === 1 || evt.evt.button === 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!Kinetic.DD.node) {
|
if(!Kinetic.DD.node) {
|
||||||
that.startDrag(evt);
|
that.startDrag(evt);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,71 @@ suite('DragAndDrop', function() {
|
|||||||
|
|
||||||
layer.add(circle);
|
layer.add(circle);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
test('right click is not for dragging', function() {
|
||||||
|
var stage = addStage();
|
||||||
|
|
||||||
|
var top = stage.content.getBoundingClientRect().top;
|
||||||
|
|
||||||
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
|
var circle = new Kinetic.Circle({
|
||||||
|
x: stage.getWidth() / 2,
|
||||||
|
y: stage.getHeight() / 2,
|
||||||
|
radius: 70,
|
||||||
|
fill: 'green',
|
||||||
|
stroke: 'black',
|
||||||
|
strokeWidth: 4,
|
||||||
|
name: 'myCircle',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.add(circle);
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
stage._mousedown({
|
||||||
|
clientX: 291,
|
||||||
|
clientY: 112 + top,
|
||||||
|
});
|
||||||
|
|
||||||
|
stage._mousemove({
|
||||||
|
clientX: 311,
|
||||||
|
clientY: 112 + top,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert(circle.isDragging(), 'dragging is ok');
|
||||||
|
|
||||||
|
Kinetic.DD._endDragBefore();
|
||||||
|
stage._mouseup({
|
||||||
|
clientX: 291,
|
||||||
|
clientY: 112 + top
|
||||||
|
});
|
||||||
|
Kinetic.DD._endDragAfter({dragEndNode:circle});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
stage._mousedown({
|
||||||
|
clientX: 291,
|
||||||
|
clientY: 112 + top,
|
||||||
|
button: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
stage._mousemove({
|
||||||
|
clientX: 311,
|
||||||
|
clientY: 112 + top,
|
||||||
|
button: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
assert(circle.isDragging() === false, 'no dragging with right click');
|
||||||
|
|
||||||
|
Kinetic.DD._endDragBefore();
|
||||||
|
stage._mouseup({
|
||||||
|
clientX: 291,
|
||||||
|
clientY: 112 + top,
|
||||||
|
button: 2
|
||||||
|
});
|
||||||
|
Kinetic.DD._endDragAfter({dragEndNode:circle});
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user