Skip to content

Commit

Permalink
Fixed #5167
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici authored and Çağatay Çivici committed Apr 19, 2018
1 parent 8243fe8 commit 16a01fa
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/app/components/dragdrop/dragdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class Draggable implements AfterViewInit, OnDestroy {

dragListener: any;

mouseOverListener: any;
mouseDownListener: any;

mouseLeaveListener: any;
mouseUpListener: any;

constructor(public el: ElementRef, public domHandler: DomHandler, public zone: NgZone) {}

Expand All @@ -56,23 +56,23 @@ export class Draggable implements AfterViewInit, OnDestroy {
}

bindMouseListeners() {
if (!this.mouseOverListener && this.mouseLeaveListener) {
if (!this.mouseDownListener && !this.mouseUpListener) {
this.zone.runOutsideAngular(() => {
this.mouseOverListener = this.mouseover.bind(this);
this.mouseLeaveListener = this.mouseleave.bind(this);
this.el.nativeElement.addEventListener('mouseover', this.mouseOverListener);
this.el.nativeElement.addEventListener('mouseleave', this.mouseLeaveListener);
this.mouseDownListener = this.mousedown.bind(this);
this.mouseUpListener = this.mouseup.bind(this);
this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);
this.el.nativeElement.addEventListener('mouseup', this.mouseUpListener);
});
}
}

unbindMouseListeners() {
if (this.mouseOverListener && this.mouseLeaveListener) {
if (this.mouseDownListener && this.mouseUpListener) {
this.zone.runOutsideAngular(() => {
this.el.nativeElement.removeEventListener('mouseover', this.mouseOverListener);
this.el.nativeElement.removeEventListener('mouseleave', this.mouseLeaveListener);
this.mouseOverListener = null;
this.mouseLeaveListener = null;
this.el.nativeElement.removeEventListener('mousedown', this.mouseDownListener);
this.el.nativeElement.removeEventListener('mouseup', this.mouseUpListener);
this.mouseDownListener = null;
this.mouseUpListener = null;
});
}
}
Expand Down Expand Up @@ -104,11 +104,11 @@ export class Draggable implements AfterViewInit, OnDestroy {
this.unbindDragListener();
}

mouseover(event) {
mousedown(event) {
this.handle = event.target;
}

mouseleave(event) {
mouseup(event) {
this.handle = null;
}

Expand Down

0 comments on commit 16a01fa

Please sign in to comment.