Drag event seems not to be triggered (while click in the same element do work)

Viewed 15

I write this JS class code:

class wxPopUp{
#TypeClass = ['w-modal-container-t-ok', "w-modal-container-t-err", "w-modal-container-t-input"];
#visible = false;
#top = "5rem";
#y_pos = "5rem";
#side = "L"; 
#width = "30rem";
#height = "10rem";
#type = 0; //0=ok, 1=err, 2=input
#content = null;
window = null;
constructor(top,y_pos,side,width,height,type,movil,content){
    this.#type = type;
    this.#content = content; 
            
    const body = document.getElementsByTagName("body")[0];
    this.window = document.createElement("div")
    this.window.classList.add("w-modal-container", this.#TypeClass[type], "w-popup-off");
    this.window.append(content);
    body.append(this.window);

    this.Move(top, y_pos, side);
    this.Resize(width, height);
    if (movil) {
        this.window.addEventListener("drag", this.Drag);
        this.window.addEventListener("dragstart", this.DragStart);
        this.window.addEventListener("click", this.Click);
    }
}
Drag = (e) =>{
    console.log("drag",e);
}
DragStart = (e) =>{
    console.log("drag start", e);
}
Click = (e) =>{
    console.log("click", e);
}

// ... continua

When I click in the popup window, the console log of the click method executes perfectly. BUT when I try to drag the popup window, neither de drag nor the dragstart methods execute..

Thank you.

0 Answers
Related