Skip to content

Commit

Permalink
forgot touch support
Browse files Browse the repository at this point in the history
  • Loading branch information
Leone25 committed Jun 5, 2024
1 parent 25a3616 commit 6300601
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions templates/sugo.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,33 @@
e.preventDefault();
this.mouseDown = true;
const ctx = this.$refs.signature.getContext('2d');
let x = e.touches[0].clientX - this.$refs.signature.getBoundingClientRect().left;
let y = e.touches[0].clientY - this.$refs.signature.getBoundingClientRect().top;
ctx.beginPath();
ctx.moveTo(e.touches[0].clientX - this.$refs.signature.getBoundingClientRect().left, e.touches[0].clientY - this.$refs.signature.getBoundingClientRect().top);
ctx.arc(x, y, 1.5, 0, 2 * Math.PI);
ctx.fill();
ctx.beginPath();
ctx.moveTo(x, y);
},
handleTouchMove(e) {
e.preventDefault();
if (!this.mouseDown) return;
const ctx = this.$refs.signature.getContext('2d');
let x = e.touches[0].clientX - this.$refs.signature.getBoundingClientRect().left;
let y = e.touches[0].clientY - this.$refs.signature.getBoundingClientRect().top;
ctx.lineWidth = 3;
ctx.lineTo(e.touches[0].clientX - this.$refs.signature.getBoundingClientRect().left, e.touches[0].clientY - this.$refs.signature.getBoundingClientRect().top);
ctx.lineTo(x, y);
ctx.stroke();
},
handleTouchEnd(e) {
e.preventDefault();
this.mouseDown = false;
const ctx = this.$refs.signature.getContext('2d');
let x = e.touches[0].clientX - this.$refs.signature.getBoundingClientRect().left;
let y = e.touches[0].clientY - this.$refs.signature.getBoundingClientRect().top;
ctx.beginPath();
ctx.arc(x, y, 1.5, 0, 2 * Math.PI);
ctx.fill();
},
clear() {
const ctx = this.$refs.signature.getContext('2d');
Expand Down

0 comments on commit 6300601

Please sign in to comment.