mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 02:27:53 +08:00
fix transformer clone. close #1457
This commit is contained in:
parent
066fec0248
commit
c29300e8cf
22
package.json
22
package.json
@ -88,11 +88,11 @@
|
||||
}
|
||||
],
|
||||
"devDependencies": {
|
||||
"@parcel/transformer-image": "2.7.0",
|
||||
"@size-limit/preset-big-lib": "^8.0.0",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"canvas": "^2.9.3",
|
||||
"chai": "4.3.6",
|
||||
"@parcel/transformer-image": "2.8.2",
|
||||
"@size-limit/preset-big-lib": "^8.1.0",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"canvas": "^2.10.2",
|
||||
"chai": "4.3.7",
|
||||
"filehound": "^1.17.6",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-concat": "^2.6.1",
|
||||
@ -105,19 +105,19 @@
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"gulp-uglify-es": "^3.0.0",
|
||||
"gulp-util": "^3.0.8",
|
||||
"mocha": "10.0.0",
|
||||
"mocha": "10.2.0",
|
||||
"mocha-headless-chrome": "^4.0.0",
|
||||
"parcel": "2.7.0",
|
||||
"parcel": "2.8.2",
|
||||
"process": "^0.11.10",
|
||||
"rollup": "^2.77.2",
|
||||
"rollup": "^3.7.5",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"rollup-plugin-typescript2": "^0.32.1",
|
||||
"size-limit": "^8.0.0",
|
||||
"rollup-plugin-typescript2": "^0.34.1",
|
||||
"size-limit": "^8.1.0",
|
||||
"ts-mocha": "^10.0.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4"
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"keywords": [
|
||||
"canvas",
|
||||
|
@ -1219,6 +1219,11 @@ export class Transformer extends Group {
|
||||
return Node.prototype.toObject.call(this);
|
||||
}
|
||||
|
||||
// overwrite clone to NOT use method from Container
|
||||
clone(obj?: any) {
|
||||
var node = Node.prototype.clone.call(this, obj);
|
||||
return node as this;
|
||||
}
|
||||
getClientRect() {
|
||||
if (this.nodes().length > 0) {
|
||||
return super.getClientRect();
|
||||
|
@ -4744,4 +4744,29 @@ describe('Transformer', function () {
|
||||
assert.notDeepEqual(layerClientRect, rectClientRect);
|
||||
assert.deepEqual(layerClientRect, trClientRect);
|
||||
});
|
||||
|
||||
it.only('cloning of transformer should double create child elements', function () {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
||||
var rect = new Konva.Rect({
|
||||
x: 100,
|
||||
y: 60,
|
||||
draggable: true,
|
||||
width: 100,
|
||||
height: 100,
|
||||
fill: 'yellow',
|
||||
});
|
||||
layer.add(rect);
|
||||
|
||||
var tr = new Konva.Transformer({
|
||||
nodes: [rect],
|
||||
});
|
||||
layer.add(tr);
|
||||
|
||||
const clone = tr.clone();
|
||||
assert.equal(clone.getChildren().length, tr.getChildren().length);
|
||||
assert.equal(clone.nodes().length, 0);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user