Skip to content

Commit

Permalink
feat: add cancel event when mouseonly
Browse files Browse the repository at this point in the history
  • Loading branch information
CecoMilchev committed Aug 11, 2023
1 parent c2aaca2 commit 9ecdca6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,25 @@ export class Draggable {

if ((which && which > 1) || this._ignoreMouse) {
bind(this.document, "contextmenu", preventDefault);

this.cancelDrag(e);

this._cancelHandler(e);

return;
}

if (!this._clickMoveClick) {
bind(this.document, "mouseup", this._mouseup);
bind(this.document, "mousemove", this._mousemove);
bind(this.document, "contextmenu", preventDefault);
this._pressHandler(e);
} else {
if (this._isDragging) {
bind(this.document, "mouseup", this._mouseup);
} else {
bind(this.document, "mousemove", this._mousemove);
bind(this.document, "keydown", this._keydown);
this._pressHandler(e);
}

Expand All @@ -123,6 +130,12 @@ export class Draggable {
this._mouseup = (e) => {
unbind(this.document, "mousemove", this._mousemove);
unbind(this.document, "mouseup", this._mouseup);

if (this.clickMoveClick){
unbind(this.document, "keydown", this._keydown);
unbind(this.document, "contextmenu", preventDefault);
}

this._releaseHandler(e);
};

Expand Down

0 comments on commit 9ecdca6

Please sign in to comment.