Merge branch 'fix-DblClick-after-dragging' of git://github.com/kzhdev/KineticJS into kzhdev-fix-DblClick-after-dragging

Conflicts:
	test/unit/Stage-test.js
This commit is contained in:
Лаврёнов Антон
2014-04-30 09:04:06 +08:00
3 changed files with 75 additions and 4 deletions

View File

@@ -450,5 +450,71 @@ suite('Stage', function() {
stage.add(layer1, layer2, layer3);
assert.equal(stage.getLayers().length, 3, 'stage has exactly three layers');
});
// ======================================================
test('test drag and click', function() {
var stage = addStage();
var layer = new Kinetic.Layer();
var rect = new Kinetic.Rect({
x: 50,
y: 50,
width: 50,
height: 50,
fill: 'red',
draggable: true
});
layer.add(rect);
stage.add(layer);
rect.on('dblclick', function() {
assert(false, 'double click fired');
});
var top = stage.content.getBoundingClientRect().top,
clientY = 60 + top;
// simulate dragging
stage._mousedown({
clientX: 60,
clientY: clientY
});
stage._mousemove({
clientX: 61,
clientY: clientY
});
stage._mousemove({
clientX: 62,
clientY: clientY
});
stage._mousemove({
clientX: 63,
clientY: clientY
});
stage._mousemove({
clientX: 64,
clientY: clientY
});
Kinetic.DD._endDragBefore();
stage._mouseup({
clientX: 65,
clientY: clientY
});
Kinetic.DD._endDragAfter({dragEndNode:rect});
// simulate click
stage._mousedown({
clientX: 66,
clientY: clientY
});
stage._mouseup({
clientX: 66,
clientY: clientY
});
})
});