You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
796 B
HTML

<!dhtml lib>
<konva-editor>
<script>
this.stage = null;
this._resizeObserver = null;
mounted() {
const width = this.root.clientWidth || 500;
const height = this.root.clientHeight || 500;
this.stage = new Konva.Stage({
container: this.root,
width,
height,
});
this._resizeObserver = new ResizeObserver(() => {
if (!this.stage) return;
this.stage.width(this.root.clientWidth);
this.stage.height(this.root.clientHeight);
this.stage.batchDraw();
});
this._resizeObserver.observe(this.root);
}
unmounted() {
this._resizeObserver?.disconnect();
this._resizeObserver = null;
this.stage?.destroy();
this.stage = null;
}
</script>
</konva-editor>