Skip to content

Commit

Permalink
fix(draggable): allow events to be dragged back into their original p…
Browse files Browse the repository at this point in the history
…ositions
  • Loading branch information
Matt Lewis committed Dec 11, 2016
1 parent 4b10027 commit 7831903
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export class Draggable implements OnInit, OnDestroy {
return previous.x !== next.x || previous.y !== next.y;
})
.map(([previous, next]) => next)
.filter(({x, y}) => x !== 0 || y !== 0)
.subscribe(({x, y, currentDrag, clientX, clientY}) => {
this.dragging.next({x, y});
this.setCssTransform(`translate(${x}px, ${y}px)`);
Expand Down
12 changes: 0 additions & 12 deletions test/draggable.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,6 @@ describe('draggable directive', () => {
expect(fixture.componentInstance.dragging).to.have.been.calledOnce;
});

it('should not call the dragging event with {x: 0, y: 0}', () => {
fixture.componentInstance.dragSnapGrid = {y: 10, x: 10};
fixture.detectChanges();
const draggableElement: HTMLElement = fixture.componentInstance.draggable.element.nativeElement;
triggerDomEvent('mousedown', draggableElement, {clientX: 10, clientY: 5});
triggerDomEvent('mousemove', draggableElement, {clientX: 12, clientY: 7});
expect(fixture.componentInstance.dragging).not.to.have.been.called;
triggerDomEvent('mousemove', draggableElement, {clientX: 12, clientY: 15});
expect(fixture.componentInstance.dragging).to.have.been.calledOnce;
expect(fixture.componentInstance.dragging).to.have.been.calledWith({x: 0, y: 10});
});

it('should allow drags to be validated', () => {
fixture.componentInstance.validateDrag = ({x, y}) => x > 0 && y > 0;
fixture.detectChanges();
Expand Down

0 comments on commit 7831903

Please sign in to comment.