Skip to content

Commit

Permalink
优化尺寸调整
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed Mar 25, 2020
1 parent d900592 commit 785cc5d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
26 changes: 14 additions & 12 deletions dist/klinecharts.development.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/klinecharts.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/klinecharts.production.min.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions src/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@ class View {
* @param height
*/
setSize (width, height) {
this._redraw(() => {
const pixelRatio = getPixelRatio(this._ctx)
this._width = width
this._height = height
this._canvas.style.top = '0'
this._canvas.style.width = `${width}px`
this._canvas.style.height = `${height}px`
this._canvas.width = width * pixelRatio
this._canvas.height = height * pixelRatio
this._ctx.scale(pixelRatio, pixelRatio)
// this._ctx.translate(0.5, 0.5)
})
if (this._width !== width || this._height !== height) {
this._redraw(() => {
const pixelRatio = getPixelRatio(this._ctx)
this._width = width
this._height = height
this._canvas.style.top = '0'
this._canvas.style.width = `${width}px`
this._canvas.style.height = `${height}px`
this._canvas.width = width * pixelRatio
this._canvas.height = height * pixelRatio
this._ctx.scale(pixelRatio, pixelRatio)
// this._ctx.translate(0.5, 0.5)
})
}
}

/**
Expand Down

0 comments on commit 785cc5d

Please sign in to comment.