Czy to dlatego że ta funkcja callback nie staje się częścią wywołujacej ją klasy?
kod online https://jsfiddle.net/eojfb8vc/
Kod
class testObj {
constructor() {
this.val = {
start: 0,
};
document.addEventListener( "mousedown", this.checkMouseDown );
document.addEventListener( "mouseup", this.checkMouseUp );
}
checkMouseDown(event) {
console.log('MOUSE DOWN #########');
console.log(this.val);
this.val.start = new Date().getTime();
}
checkMouseUp(event) {
console.log('MOUSE UP #########');
}
}
let obj = new testObj();
constructor() {
this.val = {
start: 0,
};
document.addEventListener( "mousedown", this.checkMouseDown );
document.addEventListener( "mouseup", this.checkMouseUp );
}
checkMouseDown(event) {
console.log('MOUSE DOWN #########');
console.log(this.val);
this.val.start = new Date().getTime();
}
checkMouseUp(event) {
console.log('MOUSE UP #########');
}
}
let obj = new testObj();