mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 08:46:44 +08:00
fix detach bug on destroy
This commit is contained in:
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user