add warning for clip on stage. close #456

This commit is contained in:
Anton Lavrenov
2019-02-22 20:48:00 -05:00
parent aaf0185363
commit 9c06b2ff96
3 changed files with 28 additions and 3 deletions

View File

@@ -78,6 +78,15 @@ const NO_POINTERS_MESSAGE = `Pointer position is missing and not registered by t
export const stages: Stage[] = [];
function checkNoClip(attrs: any = {}) {
if (attrs.clipFunc || attrs.clipWidth || attrs.clipHeight) {
Util.warn(
'Stage does not support clipping. Please use clip for Layers or Groups.'
);
}
return attrs;
}
/**
* Stage constructor. A stage is used to contain multiple layers
* @constructor
@@ -108,12 +117,18 @@ export class Stage extends Container {
children: Collection<BaseLayer>;
constructor(config) {
super(config);
super(checkNoClip(config));
this._buildDOM();
this._bindContentEvents();
stages.push(this);
this.on('widthChange.konva heightChange.konva', this._resizeDOM);
this.on('visibleChange.konva', this._checkVisibility);
this.on(
'clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva',
() => {
checkNoClip(this.attrs);
}
);
this._checkVisibility();
}