mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix size issue on non-resizable HiDPI canvases.
Reverting back to original behavior in #586.
This commit is contained in:
parent
3c31c0e482
commit
95a8539045
1 changed files with 13 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue