I have an element that need to drag in window, code with function work well, but when i use classes i cant understand why it doesnt.
Can you help me with manipulate_this_element()
method in codepen below?
https://codepen.io/igor-sushko/pen/oNNBvQX?editors=1011
class View {
create_staff() {
console.log("staff work!");
this.listener();
};
listener() {
console.log("listener work!");
let a = document.getElementById("AAA");
a.addEventListener("mousedown", this.mouse_down)
// .onmousedown = this.mouse_down();
};
mouse_down(e) {
let that = this;
console.log("mouse_down work!");
e.preventDefault();
document.addEventListener("mousemove", that.manipulate_this_element)
// document.onmousemove = this.manipulate_this_element();
};
manipulate_this_element() {
console.log("manipulate_this_element work!");
};
}
let a = new View();
a.create_staff();
I want to see "manipulate_this_element work!" in console when i moving mouse