跳到主要内容

Group

new Konva.Group(config)

Group constructor. Groups are used to contain shapes or other groups.

Parameters​

NameTypeDescription
configObject
isolated (optional)Booleancomposite children as one live image
x (optional)Number
y (optional)Number
width (optional)Number
height (optional)Number
visible (optional)Boolean
listening (optional)Booleanwhether or not the node is listening for events
id (optional)Stringunique id
name (optional)Stringnon-unique name
opacity (optional)Numberdetermines node opacity. Can be any number between 0 and 1
scale (optional)Objectset scale
scaleX (optional)Numberset scale x
scaleY (optional)Numberset scale y
rotation (optional)Numberrotation in degrees
offset (optional)Objectoffset from center point and rotation point
offsetX (optional)Numberset offset x
offsetY (optional)Numberset offset y
draggable (optional)Booleanmakes the node draggable. When stages are draggable, you can drag and drop the entire stage by dragging any portion of the stage
dragDistance (optional)Number
dragBoundFunc (optional)function* @param {Object} [config.clip] set clip
clipX (optional)Numberset clip x
clipY (optional)Numberset clip y
clipWidth (optional)Numberset clip width
clipHeight (optional)Numberset clip height
clipFunc (optional)functionset clip func

Inherited from: Konva.Container

Own Methods​

isolated(isolated)​

Get or set group isolation. Default is false. An isolated group draws its children into a transparent canvas on each scene draw. The group opacity and globalCompositeOperation apply once to the completed image. Child blend modes and erasing affect only the content inside that canvas. Explicit cache() calls keep their snapshot behavior. clearCache() resumes live drawing. Hit testing keeps its normal behavior, including hits on erased content. For video or canvas sources, schedule draws when the source changes. Buffers use conservative content bounds at the destination pixel ratio. Moving the buffer origin changes native edge coverage. A few edge pixels can differ substantially; isolation does not promise pixel-identical antialiasing. Like cache(), isolation requires custom drawing (sceneFunc, charRenderFunc) to provide accurate bounds, including any pixels it paints outside its size: selfRectFunc or a getSelfRect() override. Text is bounded by its lines plus one font size, so a glyph with many stacked marks can be clipped. node-canvas shadows can change with bitmap origin. Siblings reuse a buffer; unused or oversized buffers are freed after each layer draw.

Parameters:

  • isolated (Boolean)

Returns: Boolean

Example:

const group = new Konva.Group({ isolated: true, opacity: 0.5 });
group.add(shape1, shape2);
group.isolated(false);

Inherited Methods​

Konva.Group also has all methods of its parent classes. Each link below opens the full documentation of the method on the class that defines it.

From Konva.Container​

From Konva.Node​