mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 16:53:06 +08:00
Merge pull request #807 from bluehymn/feat/container.add-fix-ts-error
fix container.add ts arguments error. #806
This commit is contained in:
@@ -116,22 +116,23 @@ export abstract class Container<ChildType extends Node> extends Node<
|
|||||||
* // remember to redraw layer if you changed something
|
* // remember to redraw layer if you changed something
|
||||||
* layer.draw();
|
* layer.draw();
|
||||||
*/
|
*/
|
||||||
add(child: ChildType) {
|
add(...children: ChildType[]) {
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
this.add(arguments[i]);
|
this.add(arguments[i]);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
var child = arguments[0];
|
||||||
if (child.getParent()) {
|
if (child.getParent()) {
|
||||||
child.moveTo(this);
|
child.moveTo(this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
var children = this.children;
|
var _children = this.children;
|
||||||
this._validateAdd(child);
|
this._validateAdd(child);
|
||||||
child.index = children.length;
|
child.index = _children.length;
|
||||||
child.parent = this;
|
child.parent = this;
|
||||||
children.push(child);
|
_children.push(child);
|
||||||
this._fire('add', {
|
this._fire('add', {
|
||||||
child: child
|
child: child
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user