Added touch support
This commit is contained in:
@@ -44,6 +44,7 @@ export default {
|
|||||||
this.canvas.width = window.innerWidth
|
this.canvas.width = window.innerWidth
|
||||||
this.canvas.height = window.innerHeight
|
this.canvas.height = window.innerHeight
|
||||||
this.canvas.addEventListener('mousemove', this.mouseEvent)
|
this.canvas.addEventListener('mousemove', this.mouseEvent)
|
||||||
|
this.canvas.addEventListener('touchmove', this.touchEvent)
|
||||||
this.renderTimer = setInterval(this.render, 1000 / 60)
|
this.renderTimer = setInterval(this.render, 1000 / 60)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -137,6 +138,16 @@ export default {
|
|||||||
this.mouse.x = event.clientX - rect.left
|
this.mouse.x = event.clientX - rect.left
|
||||||
this.mouse.y = event.clientY - rect.top
|
this.mouse.y = event.clientY - rect.top
|
||||||
|
|
||||||
|
this.sendAngleUpdate()
|
||||||
|
},
|
||||||
|
touchEvent (event) {
|
||||||
|
var rect = this.canvas.getBoundingClientRect()
|
||||||
|
this.mouse.x = event.touch[0].clientX - rect.left
|
||||||
|
this.mouse.y = event.touch[0].clientY - rect.top
|
||||||
|
|
||||||
|
this.sendAngleUpdate()
|
||||||
|
},
|
||||||
|
sendAngleUpdate () {
|
||||||
var dx = this.mouse.x - this.canvas.width / 2
|
var dx = this.mouse.x - this.canvas.width / 2
|
||||||
var dy = this.mouse.y - this.canvas.height / 2
|
var dy = this.mouse.y - this.canvas.height / 2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user