Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
FunnyDoggs authored Feb 26, 2024
1 parent eedcac5 commit f42f612
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,24 @@
}

makeDraggable() {
this.windowElement.onmousedown = (e) => this.dragMouseDown(e);
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;

this.dragMouseDown = (e) => {
e = e || window.event;
this.titleBar.onmousedown = (e) => {
e.preventDefault();
this.pos3 = e.clientX;
this.pos4 = e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = () => this.closeDragElement();
document.onmousemove = (e) => this.elementDrag(e);
};

this.elementDrag = (e) => {
e = e || window.event;
e.preventDefault();
this.pos1 = this.pos3 - e.clientX;
this.pos2 = this.pos4 - e.clientY;
this.pos3 = e.clientX;
this.pos4 = e.clientY;
this.windowElement.style.top = (this.windowElement.offsetTop - this.pos2) + "px";
this.windowElement.style.left = (this.windowElement.offsetLeft - this.pos1) + "px";
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
this.windowElement.style.top = (this.windowElement.offsetTop - pos2) + "px";
this.windowElement.style.left = (this.windowElement.offsetLeft - pos1) + "px";
};

this.closeDragElement = () => {
Expand Down

0 comments on commit f42f612

Please sign in to comment.