|
@ -208,8 +208,8 @@ class Canvas { |
|
|
this.frame.canvas.style.width = '100%'; |
|
|
this.frame.canvas.style.width = '100%'; |
|
|
this.frame.canvas.style.height = '100%'; |
|
|
this.frame.canvas.style.height = '100%'; |
|
|
|
|
|
|
|
|
this.frame.canvas.width = this.frame.canvas.clientWidth * this.pixelRatio; |
|
|
|
|
|
this.frame.canvas.height = this.frame.canvas.clientHeight * this.pixelRatio; |
|
|
|
|
|
|
|
|
this.frame.canvas.width = Math.round(this.frame.canvas.clientWidth * this.pixelRatio); |
|
|
|
|
|
this.frame.canvas.height = Math.round(this.frame.canvas.clientHeight * this.pixelRatio); |
|
|
|
|
|
|
|
|
this.options.width = width; |
|
|
this.options.width = width; |
|
|
this.options.height = height; |
|
|
this.options.height = height; |
|
@ -220,18 +220,23 @@ class Canvas { |
|
|
// this would adapt the width of the canvas to the width from 100% if and only if
|
|
|
// this would adapt the width of the canvas to the width from 100% if and only if
|
|
|
// there is a change.
|
|
|
// there is a change.
|
|
|
|
|
|
|
|
|
if (this.frame.canvas.width != this.frame.canvas.clientWidth * this.pixelRatio) { |
|
|
|
|
|
this.frame.canvas.width = this.frame.canvas.clientWidth * this.pixelRatio; |
|
|
|
|
|
|
|
|
if (this.frame.canvas.width != Math.round(this.frame.canvas.clientWidth * this.pixelRatio)) { |
|
|
|
|
|
this.frame.canvas.width = Math.round(this.frame.canvas.clientWidth * this.pixelRatio); |
|
|
emitEvent = true; |
|
|
emitEvent = true; |
|
|
} |
|
|
} |
|
|
if (this.frame.canvas.height != this.frame.canvas.clientHeight * this.pixelRatio) { |
|
|
|
|
|
this.frame.canvas.height = this.frame.canvas.clientHeight * this.pixelRatio; |
|
|
|
|
|
|
|
|
if (this.frame.canvas.height != Math.round(this.frame.canvas.clientHeight * this.pixelRatio)) { |
|
|
|
|
|
this.frame.canvas.height = Math.round(this.frame.canvas.clientHeight * this.pixelRatio); |
|
|
emitEvent = true; |
|
|
emitEvent = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (emitEvent === true) { |
|
|
if (emitEvent === true) { |
|
|
this.body.emitter.emit('resize', {width:this.frame.canvas.width / this.pixelRatio, height:this.frame.canvas.height / this.pixelRatio, oldWidth: oldWidth / this.pixelRatio, oldHeight: oldHeight / this.pixelRatio}); |
|
|
|
|
|
|
|
|
this.body.emitter.emit('resize', { |
|
|
|
|
|
width:Math.round(this.frame.canvas.width / this.pixelRatio), |
|
|
|
|
|
height:Math.round(this.frame.canvas.height / this.pixelRatio), |
|
|
|
|
|
oldWidth: Math.round(oldWidth / this.pixelRatio), |
|
|
|
|
|
oldHeight: Math.round(oldHeight / this.pixelRatio) |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return emitEvent; |
|
|
return emitEvent; |
|
|