Skip to content

Commit 7831903

Browse files
author
Matt Lewis
committed
fix(draggable): allow events to be dragged back into their original positions
1 parent 4b10027 commit 7831903

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

src/draggable.directive.ts

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export class Draggable implements OnInit, OnDestroy {
134134
return previous.x !== next.x || previous.y !== next.y;
135135
})
136136
.map(([previous, next]) => next)
137-
.filter(({x, y}) => x !== 0 || y !== 0)
138137
.subscribe(({x, y, currentDrag, clientX, clientY}) => {
139138
this.dragging.next({x, y});
140139
this.setCssTransform(`translate(${x}px, ${y}px)`);

test/draggable.directive.spec.ts

-12
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,6 @@ describe('draggable directive', () => {
217217
expect(fixture.componentInstance.dragging).to.have.been.calledOnce;
218218
});
219219

220-
it('should not call the dragging event with {x: 0, y: 0}', () => {
221-
fixture.componentInstance.dragSnapGrid = {y: 10, x: 10};
222-
fixture.detectChanges();
223-
const draggableElement: HTMLElement = fixture.componentInstance.draggable.element.nativeElement;
224-
triggerDomEvent('mousedown', draggableElement, {clientX: 10, clientY: 5});
225-
triggerDomEvent('mousemove', draggableElement, {clientX: 12, clientY: 7});
226-
expect(fixture.componentInstance.dragging).not.to.have.been.called;
227-
triggerDomEvent('mousemove', draggableElement, {clientX: 12, clientY: 15});
228-
expect(fixture.componentInstance.dragging).to.have.been.calledOnce;
229-
expect(fixture.componentInstance.dragging).to.have.been.calledWith({x: 0, y: 10});
230-
});
231-
232220
it('should allow drags to be validated', () => {
233221
fixture.componentInstance.validateDrag = ({x, y}) => x > 0 && y > 0;
234222
fixture.detectChanges();

0 commit comments

Comments
 (0)