mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 16:53:06 +08:00
Merge branch 'master' of https://github.com/deart1mer/konva into deart1mer-master
This commit is contained in:
@@ -525,6 +525,7 @@
|
|||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var shape = this.getIntersection(this.getPointerPosition()),
|
var shape = this.getIntersection(this.getPointerPosition()),
|
||||||
clickStartShape = this.clickStartShape,
|
clickStartShape = this.clickStartShape,
|
||||||
|
clickEndShape = this.clickEndShape,
|
||||||
fireDblClick = false,
|
fireDblClick = false,
|
||||||
dd = Konva.DD;
|
dd = Konva.DD;
|
||||||
|
|
||||||
@@ -543,6 +544,7 @@
|
|||||||
}, Konva.dblClickWindow);
|
}, Konva.dblClickWindow);
|
||||||
|
|
||||||
if (shape && shape.isListening()) {
|
if (shape && shape.isListening()) {
|
||||||
|
this.clickEndShape = shape;
|
||||||
shape._fireAndBubble(MOUSEUP, { evt: evt });
|
shape._fireAndBubble(MOUSEUP, { evt: evt });
|
||||||
|
|
||||||
// detect if click or double click occurred
|
// detect if click or double click occurred
|
||||||
@@ -553,7 +555,11 @@
|
|||||||
) {
|
) {
|
||||||
shape._fireAndBubble(CLICK, { evt: evt });
|
shape._fireAndBubble(CLICK, { evt: evt });
|
||||||
|
|
||||||
if (fireDblClick) {
|
if (
|
||||||
|
fireDblClick &&
|
||||||
|
clickEndShape &&
|
||||||
|
clickEndShape._id === shape._id
|
||||||
|
) {
|
||||||
shape._fireAndBubble(DBL_CLICK, { evt: evt });
|
shape._fireAndBubble(DBL_CLICK, { evt: evt });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1412,6 +1412,72 @@ suite('MouseEvents', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
test('test dblclick to a wrong target', function () {
|
||||||
|
var stage = addStage();
|
||||||
|
var layer = new Konva.Layer();
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
var leftRect = new Konva.Rect({
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
fill: 'red'
|
||||||
|
});
|
||||||
|
layer.add(leftRect);
|
||||||
|
|
||||||
|
var rightRect = new Konva.Rect({
|
||||||
|
x: 100,
|
||||||
|
y: 0,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
fill: 'blue'
|
||||||
|
});
|
||||||
|
layer.add(rightRect);
|
||||||
|
|
||||||
|
stage.draw();
|
||||||
|
|
||||||
|
var leftRectSingleClick = 0;
|
||||||
|
var rightRectSingleClick = 0;
|
||||||
|
var rightRectDblClick = 0;
|
||||||
|
|
||||||
|
leftRect.on('click', function () {
|
||||||
|
leftRectSingleClick++;
|
||||||
|
});
|
||||||
|
rightRect.on('click', function () {
|
||||||
|
rightRectSingleClick++;
|
||||||
|
});
|
||||||
|
rightRect.on('dblclick', function () {
|
||||||
|
rightRectDblClick++;
|
||||||
|
});
|
||||||
|
|
||||||
|
stage.simulateMouseDown({
|
||||||
|
x: 50,
|
||||||
|
y: 50
|
||||||
|
});
|
||||||
|
stage.simulateMouseUp({
|
||||||
|
x: 50,
|
||||||
|
y: 50
|
||||||
|
});
|
||||||
|
assert.equal(leftRectSingleClick, 1, 'leftRect trigger a click');
|
||||||
|
|
||||||
|
stage.simulateMouseDown({
|
||||||
|
x: 150,
|
||||||
|
y: 50
|
||||||
|
});
|
||||||
|
stage.simulateMouseUp({
|
||||||
|
x: 150,
|
||||||
|
y: 50
|
||||||
|
});
|
||||||
|
assert.equal(rightRectSingleClick, 1, 'rightRect trigger a click');
|
||||||
|
assert.equal(
|
||||||
|
rightRectDblClick,
|
||||||
|
0,
|
||||||
|
'rightRect dblClick should not trigger'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
test('test mouseleave + mouseenter with deep nesting', function() {
|
test('test mouseleave + mouseenter with deep nesting', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
|||||||
Reference in New Issue
Block a user