Skip to content

Commit

Permalink
fix: revert duplicate dragging fix as it caused worse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lewis committed Dec 10, 2016
1 parent 455de31 commit 7476301
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
30 changes: 8 additions & 22 deletions src/draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,15 @@ export class Draggable implements OnInit, OnDestroy {
})
.filter(({x, y}) => !this.validateDrag || this.validateDrag({x, y}));

mouseDrag.subscribe(({x, y, currentDrag, clientX, clientY}) => {
this.setCssTransform(`translate(${x}px, ${y}px)`);
currentDrag.next({
clientX,
clientY,
dropData: this.dropData
});
});

Observable
.merge(
mouseDrag.take(1).map(value => [, value]),
mouseDrag.pairwise()
)
.filter(([previous, next]) => {
if (!previous) {
return true;
}
return previous.x !== next.x || previous.y !== next.y;
})
.map(([previous, next]) => next)
mouseDrag
.filter(({x, y}) => x !== 0 || y !== 0)
.subscribe(({x, y}) => {
.subscribe(({x, y, currentDrag, clientX, clientY}) => {
this.setCssTransform(`translate(${x}px, ${y}px)`);
currentDrag.next({
clientX,
clientY,
dropData: this.dropData
});
this.dragging.next({x, y});
});

Expand Down
2 changes: 1 addition & 1 deletion test/draggable.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe('draggable directive', () => {
expect(draggableElement.style.cursor).not.to.be.ok;
});

it('should not call the dragging event multiple times with the same values', () => {
xit('should not call the dragging event multiple times with the same values', () => {
fixture.componentInstance.dragSnapGrid = {y: 10, x: 10};
fixture.detectChanges();
const draggableElement: HTMLElement = fixture.componentInstance.draggable.element.nativeElement;
Expand Down

0 comments on commit 7476301

Please sign in to comment.