Fix size issue on non-resizable HiDPI canvases.

Reverting back to original behavior in #586.
This commit is contained in:
Jürg Lehni 2015-01-02 14:38:06 +01:00
parent 3c31c0e482
commit 95a8539045

View file

@ -61,11 +61,21 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
_setViewSize: function(size) {
var element = this._element,
pixelRatio = this._pixelRatio;
pixelRatio = this._pixelRatio,
width = size.width,
height = size.height;
// Upscale the canvas if the pixel ratio is more than 1.
element.width = size.width * pixelRatio;
element.height = size.height * pixelRatio;
element.width = width * pixelRatio;
element.height = height * pixelRatio;
if (pixelRatio !== 1) {
// We need to set the correct size on non-resizable canvases through
// their style when HiDPI is active, as otherwise they would appear
// too big.
if (!PaperScope.hasAttribute(element, 'resize')) {
var style = element.style;
style.width = width + 'px';
style.height = height + 'px';
}
// Scale the context to counter the fact that we've manually scaled
// our canvas element.
this._context.scale(pixelRatio, pixelRatio);