提交 bcbfbe89 编写于 作者: Q qiang

fix: 修复低版本安卓上 canvas 绘制坐标比实际值小的问题 question/105866

上级 0c8b008e
......@@ -158,5 +158,8 @@ if (pixelRatio !== 1) {
export function wrapper (canvas) {
canvas.width = canvas.offsetWidth * pixelRatio
canvas.height = canvas.offsetHeight * pixelRatio
canvas.getContext('2d').__hidpi__ = true
canvas.__hidpi__ = true
// 避免低版本安卓上 context 实例被回收
canvas.__context2d__ = canvas.getContext('2d')
canvas.__context2d__.__hidpi__ = true
}
......@@ -107,10 +107,7 @@ export default {
this._images = {}
},
mounted () {
this._resize({
width: this.$refs.sensor.$el.offsetWidth,
height: this.$refs.sensor.$el.offsetHeight
})
this._resize()
},
beforeDestroy () {
const canvas = this.$refs.canvas
......@@ -131,10 +128,10 @@ export default {
if (canvas.width > 0 && canvas.height > 0) {
var context = canvas.getContext('2d')
var imageData = context.getImageData(0, 0, canvas.width, canvas.height)
wrapper(this.$refs.canvas)
wrapper(canvas)
context.putImageData(imageData, 0, 0)
} else {
wrapper(this.$refs.canvas)
wrapper(canvas)
}
},
_touchmove (event) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册