fix detach bug on destroy

This commit is contained in:
Anton Lavrenov
2020-04-23 11:33:00 -05:00
parent f58635bbf6
commit b657111578
4 changed files with 1373 additions and 59 deletions

1407
konva.js

File diff suppressed because it is too large Load Diff

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -463,9 +463,11 @@ export class Transformer extends Group {
*/
detach() {
// remove events
this._nodes.forEach(node => {
node.off('.' + EVENTS_NAME);
});
if (this._nodes) {
this._nodes.forEach(node => {
node.off('.' + EVENTS_NAME);
});
}
this._nodes = [];
this._resetTransformCache();
}
@@ -1004,6 +1006,13 @@ export class Transformer extends Group {
return;
}
}
// let's find delta transform
// var dx = newAttrs.x - oldAttrs.x,
// dy = newAttrs.y - oldAttrs.y,
// angle = newAttrs.rotation - oldAttrs.rotation,
// scaleX = newAttrs.width / oldAttrs.width,
// scaleY = newAttrs.height / oldAttrs.height;
this._nodes.forEach(node => {
var oldRect = this.__getNodeShape(node, 0);
var newRect = transformAndRotateShape(oldRect, oldAttrs, newAttrs);

View File

@@ -1162,9 +1162,7 @@ suite('Transformer', function() {
});
layer.add(image);
var tr = new Konva.Transformer({
nodes: [image],
keepRatio: true,
centeredScaling: true
nodes: [image]
});
layer.add(tr);
layer.draw();
@@ -3713,7 +3711,7 @@ suite('Transformer', function() {
assert.equal(dragend, 1);
});
test.only('reattach from several and drag one', function() {
test('reattach from several and drag one', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);