mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 08:46:44 +08:00
Fixed "calling remove() for dragging shape will throw an error". close #184
This commit is contained in:
@@ -369,4 +369,79 @@ suite('DragAndDrop', function() {
|
||||
}, 50);
|
||||
|
||||
});
|
||||
|
||||
test('removing shape while drag and drop should no throw error', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var circle = new Konva.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.simulateMouseDown({
|
||||
x: 291,
|
||||
y: 112
|
||||
});
|
||||
|
||||
circle.remove();
|
||||
|
||||
stage.simulateMouseMove({
|
||||
x: 311,
|
||||
y: 112
|
||||
});
|
||||
|
||||
|
||||
stage.simulateMouseUp({
|
||||
x: 291,
|
||||
y: 112,
|
||||
button: 2
|
||||
});
|
||||
});
|
||||
|
||||
test('destroying shape while drag and drop should no throw error', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var circle = new Konva.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.simulateMouseDown({
|
||||
x: 291,
|
||||
y: 112
|
||||
});
|
||||
|
||||
circle.destroy();
|
||||
|
||||
stage.simulateMouseMove({
|
||||
x: 311,
|
||||
y: 112
|
||||
});
|
||||
|
||||
|
||||
stage.simulateMouseUp({
|
||||
x: 291,
|
||||
y: 112,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ suite('Enhance', function () {
|
||||
|
||||
var imageObj = new Image();
|
||||
imageObj.onload = function() {
|
||||
|
||||
|
||||
var layer = new Konva.Layer();
|
||||
var filt = new Konva.Image({
|
||||
x: 10,
|
||||
@@ -41,7 +41,7 @@ suite('Enhance', function () {
|
||||
|
||||
var imageObj = new Image();
|
||||
imageObj.onload = function() {
|
||||
|
||||
|
||||
var layer = new Konva.Layer();
|
||||
darth = new Konva.Image({
|
||||
x: 10,
|
||||
@@ -59,16 +59,16 @@ suite('Enhance', function () {
|
||||
layer.draw();
|
||||
|
||||
var tween = new Konva.Tween({
|
||||
node: darth,
|
||||
node: darth,
|
||||
duration: 2.0,
|
||||
enhance: 1.0,
|
||||
easing: Konva.Easings.EaseInOut
|
||||
});
|
||||
|
||||
|
||||
darth.on('mouseover', function() {
|
||||
tween.play();
|
||||
});
|
||||
|
||||
|
||||
darth.on('mouseout', function() {
|
||||
tween.reverse();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user