mirror of
https://github.com/konvajs/konva.git
synced 2025-04-24 19:03:56 +08:00
fix bug 169 when removing a node, be sure to also remove the drag and drop reference
This commit is contained in:
parent
3fb9576672
commit
5e16b3d7d0
@ -145,6 +145,7 @@
|
||||
this.off('mousedown.kinetic');
|
||||
this.off('touchstart.kinetic');
|
||||
};
|
||||
|
||||
/**
|
||||
* get draggable. Alias of getDraggable()
|
||||
* @name isDraggable
|
||||
|
@ -167,6 +167,12 @@
|
||||
parent.children.splice(this.index, 1);
|
||||
parent._setChildrenIndices();
|
||||
|
||||
// remove from DD
|
||||
var dd = Kinetic.DD;
|
||||
if(dd && dd.node && dd.node._id === this._id) {
|
||||
delete Kinetic.DD.node;
|
||||
}
|
||||
|
||||
// remove children
|
||||
while(this.children && this.children.length > 0) {
|
||||
this.children[0].remove();
|
||||
|
@ -1,4 +1,44 @@
|
||||
Test.Modules.DD = {
|
||||
'remove shape from onclick': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
circle.on('click', function() {
|
||||
this.remove();
|
||||
layer.draw();
|
||||
});
|
||||
|
||||
stage._mousedown({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
stage._mouseup({
|
||||
clientX: 291,
|
||||
clientY: 112 + top
|
||||
});
|
||||
|
||||
},
|
||||
'test dragstart, dragmove, dragend': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
|
Loading…
Reference in New Issue
Block a user