mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 14:39:30 -07:00
Refactor event listeners to use container for touch and wheel events
This commit is contained in:
@@ -639,28 +639,32 @@ class App {
|
||||
this.boundOnTouchDown = this.onTouchDown.bind(this)
|
||||
this.boundOnTouchMove = this.onTouchMove.bind(this)
|
||||
this.boundOnTouchUp = this.onTouchUp.bind(this)
|
||||
|
||||
window.addEventListener('resize', this.boundOnResize)
|
||||
window.addEventListener('mousewheel', this.boundOnWheel)
|
||||
window.addEventListener('wheel', this.boundOnWheel)
|
||||
window.addEventListener('mousedown', this.boundOnTouchDown)
|
||||
|
||||
this.container.addEventListener('wheel', this.boundOnWheel)
|
||||
this.container.addEventListener('mousedown', this.boundOnTouchDown)
|
||||
this.container.addEventListener('touchstart', this.boundOnTouchDown)
|
||||
|
||||
window.addEventListener('mousemove', this.boundOnTouchMove)
|
||||
window.addEventListener('mouseup', this.boundOnTouchUp)
|
||||
window.addEventListener('touchstart', this.boundOnTouchDown)
|
||||
window.addEventListener('touchmove', this.boundOnTouchMove)
|
||||
window.addEventListener('touchend', this.boundOnTouchUp)
|
||||
}
|
||||
|
||||
destroy() {
|
||||
window.cancelAnimationFrame(this.raf)
|
||||
|
||||
window.removeEventListener('resize', this.boundOnResize)
|
||||
window.removeEventListener('mousewheel', this.boundOnWheel)
|
||||
window.removeEventListener('wheel', this.boundOnWheel)
|
||||
window.removeEventListener('mousedown', this.boundOnTouchDown)
|
||||
window.removeEventListener('mousemove', this.boundOnTouchMove)
|
||||
window.removeEventListener('mouseup', this.boundOnTouchUp)
|
||||
window.removeEventListener('touchstart', this.boundOnTouchDown)
|
||||
window.removeEventListener('touchmove', this.boundOnTouchMove)
|
||||
window.removeEventListener('touchend', this.boundOnTouchUp)
|
||||
|
||||
this.container.removeEventListener('wheel', this.boundOnWheel)
|
||||
this.container.removeEventListener('mousedown', this.boundOnTouchDown)
|
||||
this.container.removeEventListener('touchstart', this.boundOnTouchDown)
|
||||
|
||||
if (this.renderer && this.renderer.gl && this.renderer.gl.canvas.parentNode) {
|
||||
this.renderer.gl.canvas.parentNode.removeChild(this.renderer.gl.canvas as HTMLCanvasElement)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user