mirror of
https://github.com/konvajs/konva.git
synced 2025-12-21 11:14:00 +08:00
began refactoring layer getIntersection method and added unit tests
This commit is contained in:
@@ -180,6 +180,73 @@ suite('MouseEvents', function() {
|
||||
Kinetic.DD._endDragAfter({dragEndNode:circle});
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('test listening true/false with clicks', 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'
|
||||
});
|
||||
|
||||
var clickCount = 0;
|
||||
|
||||
circle.on('click', function() {
|
||||
clickCount++;
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
// -----------------------------------
|
||||
stage._mousedown({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
Kinetic.DD._endDragBefore();
|
||||
stage._mouseup({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
assert.equal(clickCount, 1, 'should be 1 click');
|
||||
|
||||
// -----------------------------------
|
||||
circle.setListening(false);
|
||||
stage._mousedown({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
Kinetic.DD._endDragBefore();
|
||||
stage._mouseup({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
assert.equal(clickCount, 1, 'should be 1 click even though another click occurred');
|
||||
|
||||
// -----------------------------------
|
||||
circle.setListening(true);
|
||||
stage._mousedown({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
Kinetic.DD._endDragBefore();
|
||||
stage._mouseup({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
assert.equal(clickCount, 2, 'should be 2 clicks');
|
||||
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('click mapping', function() {
|
||||
var stage = addStage();
|
||||
|
||||
Reference in New Issue
Block a user