2019-01-01 15:59:27 -05:00
|
|
|
import { Util, Collection } from './Util';
|
|
|
|
import { Container } from './Container';
|
2019-02-27 08:06:04 -05:00
|
|
|
import { _registerNode } from './Global';
|
2019-04-08 12:17:26 -05:00
|
|
|
import { Node } from './Node';
|
2019-04-17 10:45:47 -05:00
|
|
|
import { Shape } from './Shape';
|
2019-02-24 12:06:04 -05:00
|
|
|
|
2019-01-01 15:59:27 -05:00
|
|
|
/**
|
|
|
|
* Group constructor. Groups are used to contain shapes or other groups.
|
|
|
|
* @constructor
|
|
|
|
* @memberof Konva
|
|
|
|
* @augments Konva.Container
|
|
|
|
* @param {Object} config
|
|
|
|
* @@nodeParams
|
|
|
|
* @@containerParams
|
|
|
|
* @example
|
|
|
|
* var group = new Konva.Group();
|
|
|
|
*/
|
2019-04-17 10:45:47 -05:00
|
|
|
export class Group extends Container<Group | Shape> {
|
2019-05-28 15:39:08 -05:00
|
|
|
_validateAdd(child: Node) {
|
2019-01-01 15:59:27 -05:00
|
|
|
var type = child.getType();
|
|
|
|
if (type !== 'Group' && type !== 'Shape') {
|
|
|
|
Util.throw('You may only add groups and shapes to groups.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-25 00:20:15 -05:00
|
|
|
Group.prototype.nodeType = 'Group';
|
2019-02-27 08:06:04 -05:00
|
|
|
_registerNode(Group);
|
2019-01-25 00:20:15 -05:00
|
|
|
|
2019-01-01 15:59:27 -05:00
|
|
|
Collection.mapMethods(Group);
|