I want click and move with grid along x, z and when the mousebutton is released the function end Move is called but Eventlistener for mousemove going forever.
The working project
componentDidMount() {
//this.seed();//
if (this.state.rowcolarr.length === 0) {
this.random();
}
window.addEventListener("keydown", (e) => this.handleKeyPress(e));
// window.addEventListener('mousedown', (e) => this.mouseStartmove(e),true);
// window.addEventListener('mouseup', (e) => this.mouseEndmove(e),true);
}
componentWillUnmount() {
window.removeEventListener("keydown", (e) => this.handleKeyPress(e));
// window.removeEventListener('mousedown', (e) => this.mouseStartmove(e),true);
//window.removeEventListener('mouseup', (e) => this.mouseEndmove(e),true);
}
mouseStartmove(e){
document.getElementById('aside').addEventListener('mousemove', (e) => this.angle(e));
}
mouseEndmove(){
document.getElementById('aside').removeEventListener('mousemove', (e) => this.angle(e));
}
solved
document.getElementById(“myDIV”).onmousemove = function(event) {myFunction(event)};