Skip to content
Snippets Groups Projects
Commit eda62f6d authored by Ron Lucke's avatar Ron Lucke
Browse files

fixes #373

parent b766979b
No related branches found
No related tags found
No related merge requests found
...@@ -89,6 +89,10 @@ ...@@ -89,6 +89,10 @@
@mouseup="mouseUp" @mouseup="mouseUp"
@mouseout="mouseUp" @mouseout="mouseUp"
@mouseleave="mouseUp" @mouseleave="mouseUp"
@touchstart="touchStart"
@touchmove="touchMove"
@touchend="touchEnd"
/> />
<div class="cw-canvasblock-hints"> <div class="cw-canvasblock-hints">
<div v-show="write" class="messagebox messagebox_info cw-canvasblock-text-info"> <div v-show="write" class="messagebox messagebox_info cw-canvasblock-text-info">
...@@ -408,6 +412,44 @@ export default { ...@@ -408,6 +412,44 @@ export default {
this.storeDraw(); this.storeDraw();
this.paint = false; this.paint = false;
}, },
touchStart(e) {
e.preventDefault();
if (this.write) {
return;
}
let canvas = this.$refs.canvas;
let mousePos = this.getTouchPos(canvas, e);
if(this.currentTool == 'pen') {
this.paint = true;
this.addClick(mousePos.x, mousePos.y, false);
this.redraw();
}
if(this.currentTool == 'text') {
this.write = true;
this.addClick(mousePos.x, mousePos.y, false);
}
},
touchMove(e) {
e.preventDefault();
let canvas = this.$refs.canvas;
let mousePos = this.getTouchPos(canvas, e);
if(this.paint){
this.addClick(mousePos.x, mousePos.y, true);
this.redraw();
}
},
touchEnd(e) {
this.storeDraw();
this.paint = false;
},
getTouchPos(canvasDom, touchEvent) {
var rect = canvasDom.getBoundingClientRect();
return {
x: touchEvent.touches[0].clientX - rect.left,
y: touchEvent.touches[0].clientY - rect.top
};
},
addClick(x, y, dragging) { addClick(x, y, dragging) {
this.clickX.push(x); this.clickX.push(x);
this.clickY.push(y); this.clickY.push(y);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment