Skip to content

Commit

Permalink
fix(draggable): fire dragEnd event when the event was not dragged
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
Matt Lewis committed Sep 18, 2017
1 parent b803096 commit 73d65d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export class Draggable implements OnInit, OnChanges, OnDestroy {
}
});

this.pointerMove.next(pointerDownEvent);

return pointerMove;

})
Expand Down
9 changes: 9 additions & 0 deletions test/draggable.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,13 @@ describe('draggable directive', () => {
expect(fixture.componentInstance.draggable['eventListenerSubscriptions'].touchmove).to.equal(touchMoveUnsubscribe);
});

it('should fire the dragEnd event when starting a drag but not actually moving it', () => {
const draggableElement: HTMLElement = fixture.componentInstance.draggable.element.nativeElement;
triggerDomEvent('mousedown', draggableElement, {clientX: 5, clientY: 10});
expect(fixture.componentInstance.dragStart).to.have.been.calledWith({x: 0, y: 0});
triggerDomEvent('mouseup', draggableElement, {clientX: 5, clientY: 10});
expect(fixture.componentInstance.dragEnd).to.have.been.calledWith({x: 0, y: 0});
expect(draggableElement.style.transform).not.to.be.ok;
});

});

0 comments on commit 73d65d7

Please sign in to comment.