From c6d5d892cfaa3c05de346b35009fef04e814966e Mon Sep 17 00:00:00 2001 From: DD Liu Date: Wed, 6 May 2020 22:57:11 -0400 Subject: [PATCH] Bring in adroitwhiz's changes --- src/containers/paper-canvas.css | 4 ++-- src/containers/paper-canvas.jsx | 7 ++++++- src/helper/layer.js | 9 ++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/containers/paper-canvas.css b/src/containers/paper-canvas.css index 99ef54e0..36dead46 100644 --- a/src/containers/paper-canvas.css +++ b/src/containers/paper-canvas.css @@ -1,6 +1,6 @@ .paper-canvas { - top: 1px; /* leave room for the border*/ - left: 1px; + top: 1px; /* leave room for the border */ + left: 1px; width: calc(100% - 2px); height: calc(100% - 2px); margin: auto; diff --git a/src/containers/paper-canvas.jsx b/src/containers/paper-canvas.jsx index a6858b0d..8a6db731 100644 --- a/src/containers/paper-canvas.jsx +++ b/src/containers/paper-canvas.jsx @@ -228,7 +228,12 @@ class PaperCanvas extends React.Component { window.setTimeout(() => { // Detached if (!paper.view) return; - paper.view.setViewSize(paper.DomElement.getSize(paper.view.element)); + // Prevent blurriness caused if the "CSS size" of the element is a float-- + // setting canvas dimensions to floats floors them, but we need to round instead + const elemSize = paper.DomElement.getSize(paper.view.element); + elemSize.width = Math.round(elemSize.width); + elemSize.height = Math.round(elemSize.height); + paper.view.setViewSize(elemSize); paperCanvas.props.updateViewBounds(paper.view.matrix); paperCanvas.initializeSvg(item, rotationCenterX, rotationCenterY, viewBox); }, 0); diff --git a/src/helper/layer.js b/src/helper/layer.js index a9661cf1..8f1c100b 100644 --- a/src/helper/layer.js +++ b/src/helper/layer.js @@ -65,13 +65,8 @@ const getBackgroundGuideLayer = function () { }; const _convertLayer = function (layer, format) { - if (isVector(format)) { - layer.vectorBackground.visible = true; - layer.bitmapBackground.visible = false; - } else if (isBitmap(format)) { - layer.bitmapBackground.visible = true; - layer.vectorBackground.visible = false; - } + layer.bitmapBackground.visible = isBitmap(format); + layer.vectorBackground.visible = isVector(format); }; const convertBackgroundGuideLayer = function (format) {