fix: 解决首次绘制可能出现的canvas尺寸问题

This commit is contained in:
0JARVIS0 2020-11-06 16:07:04 +08:00
parent c26ff78fe5
commit 4adce6a615

View File

@ -662,12 +662,10 @@ Component({
startPaint() { startPaint() {
this.initScreenK(); this.initScreenK();
this.downloadImages(this.properties.palette).then(async (palette) => {
const { const {
width, width,
height height
} = palette; } = this.properties.palette;
if (!width || !height) { if (!width || !height) {
console.error(`You should set width and height correctly for painter, width: ${width}, height: ${height}`); console.error(`You should set width and height correctly for painter, width: ${width}, height: ${height}`);
@ -691,7 +689,8 @@ Component({
} }
this.setData({ this.setData({
photoStyle: `width:${this.canvasWidthInPx}px;height:${this.canvasHeightInPx}px;`, photoStyle: `width:${this.canvasWidthInPx}px;height:${this.canvasHeightInPx}px;`,
}); }, function () {
this.downloadImages(this.properties.palette).then(async palette => {
if (!this.photoContext) { if (!this.photoContext) {
this.photoContext = await this.getCanvasContext(this.properties.use2D, 'photo'); this.photoContext = await this.getCanvasContext(this.properties.use2D, 'photo');
} }
@ -706,6 +705,7 @@ Component({
}); });
setStringPrototype(this.screenK, this.properties.scaleRatio); setStringPrototype(this.screenK, this.properties.scaleRatio);
}); });
});
}, },
downloadImages(palette) { downloadImages(palette) {