Avoid changing scale unless necessary

It causes the browser to redo the layout needlessly otherwise,
having annoying effects like moving the scroll position.
This commit is contained in:
Pierre Ossman 2017-02-03 12:00:13 +01:00
parent a6e52f9a73
commit 2e6a58fb15
1 changed files with 8 additions and 2 deletions

View File

@ -602,8 +602,14 @@
// style width to a number, the canvas is cleared.
// However, if you set the style width to a string
// ('NNNpx'), the canvas is scaled without clearing.
this._target.style.width = Math.round(factor * vp.w) + 'px';
this._target.style.height = Math.round(factor * vp.h) + 'px';
var width = Math.round(factor * vp.w) + 'px';
var height = Math.round(factor * vp.h) + 'px';
if ((this._target.style.width !== width) ||
(this._target.style.height !== height)) {
this._target.style.width = width;
this._target.style.height = height;
}
},
_setFillColor: function (color) {