mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
fix imageSmoothingEnabled on resize. fix #884
This commit is contained in:
@@ -37,8 +37,8 @@ export abstract class BaseLayer extends Container<Group | Shape> {
|
||||
this.on('visibleChange', this._checkVisibility);
|
||||
this._checkVisibility();
|
||||
|
||||
this.on('imageSmoothingEnabledChange', this._checkSmooth);
|
||||
this._checkSmooth();
|
||||
this.on('imageSmoothingEnabledChange', this._setSmoothEnabled);
|
||||
this._setSmoothEnabled();
|
||||
}
|
||||
// for nodejs?
|
||||
createPNGStream() {
|
||||
@@ -193,6 +193,7 @@ export abstract class BaseLayer extends Container<Group | Shape> {
|
||||
}
|
||||
setSize({ width, height }) {
|
||||
this.canvas.setSize(width, height);
|
||||
this._setSmoothEnabled();
|
||||
return this;
|
||||
}
|
||||
_toKonvaCanvas(config) {
|
||||
@@ -214,7 +215,7 @@ export abstract class BaseLayer extends Container<Group | Shape> {
|
||||
}
|
||||
}
|
||||
|
||||
_checkSmooth() {
|
||||
_setSmoothEnabled() {
|
||||
this.getContext()._context.imageSmoothingEnabled = this.imageSmoothingEnabled();
|
||||
}
|
||||
/**
|
||||
|
@@ -29,10 +29,6 @@ export class FastLayer extends BaseLayer {
|
||||
Util.throw('You may only add shapes to a fast layer.');
|
||||
}
|
||||
}
|
||||
_setCanvasSize(width, height) {
|
||||
this.canvas.setSize(width, height);
|
||||
this._checkSmooth();
|
||||
}
|
||||
hitGraphEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
11
src/Layer.ts
11
src/Layer.ts
@@ -50,10 +50,10 @@ export class Layer extends BaseLayer {
|
||||
pixelRatio: 1
|
||||
});
|
||||
|
||||
_setCanvasSize(width, height) {
|
||||
this.canvas.setSize(width, height);
|
||||
setSize({ width, height }) {
|
||||
super.setSize({ width, height });
|
||||
this.hitCanvas.setSize(width, height);
|
||||
this._checkSmooth();
|
||||
return this;
|
||||
}
|
||||
_validateAdd(child) {
|
||||
var type = child.getType();
|
||||
@@ -227,11 +227,6 @@ export class Layer extends BaseLayer {
|
||||
parent.content.appendChild(this.hitCanvas._canvas);
|
||||
}
|
||||
}
|
||||
setSize({ width, height }) {
|
||||
super.setSize({ width, height });
|
||||
this.hitCanvas.setSize(width, height);
|
||||
return this;
|
||||
}
|
||||
|
||||
hitGraphEnabled: GetSet<boolean, this>;
|
||||
}
|
||||
|
@@ -376,7 +376,7 @@ export class Stage extends Container<BaseLayer> {
|
||||
' layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.'
|
||||
);
|
||||
}
|
||||
layer._setCanvasSize(this.width(), this.height());
|
||||
layer.setSize({ width: this.width(), height: this.height() });
|
||||
|
||||
// draw layer and append canvas to container
|
||||
layer.draw();
|
||||
|
Reference in New Issue
Block a user