I have tried both of the following versions but I can't get the mousemove
eventListener to be removed. I think my limited understanding of scoping inside of classes is causing some confusion, but I'd assume this should work.
export class Line extends Graphic {
constructor() {
super()
}
handleMouseMoveWhileDrawing(e) {
console.log(e);
}
stopDrawing() {
document.removeEventListener('mouseup', this.stopDrawing)
document.removeEventListener('mousemove', this.handleMouseMoveWhileDrawing)
}
startDrawing() {
document.addEventListener('mousemove', this.handleMouseMoveWhileDrawing)
document.addEventListener('mouseup', this.stopDrawing)
}
}
new Line().startDrawing()
export class Line extends Graphic {
constructor() {
super()
this.handleMouseMoveWhileDrawing = function(e) {
console.log(e);
}
}
stopDrawing() {
document.removeEventListener('mouseup', this.stopDrawing)
document.removeEventListener('mousemove', this.handleMouseMoveWhileDrawing)
}
startDrawing() {
document.addEventListener('mousemove', this.handleMouseMoveWhileDrawing)
document.addEventListener('mouseup', this.stopDrawing)
}
}
new Line().startDrawing()
Any help would be greatly appreciated.