Skip to content

Commit 7476301

Browse files
author
Matt Lewis
committed
fix: revert duplicate dragging fix as it caused worse errors
1 parent 455de31 commit 7476301

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

src/draggable.directive.ts

+8-22
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,15 @@ export class Draggable implements OnInit, OnDestroy {
120120
})
121121
.filter(({x, y}) => !this.validateDrag || this.validateDrag({x, y}));
122122

123-
mouseDrag.subscribe(({x, y, currentDrag, clientX, clientY}) => {
124-
this.setCssTransform(`translate(${x}px, ${y}px)`);
125-
currentDrag.next({
126-
clientX,
127-
clientY,
128-
dropData: this.dropData
129-
});
130-
});
131-
132-
Observable
133-
.merge(
134-
mouseDrag.take(1).map(value => [, value]),
135-
mouseDrag.pairwise()
136-
)
137-
.filter(([previous, next]) => {
138-
if (!previous) {
139-
return true;
140-
}
141-
return previous.x !== next.x || previous.y !== next.y;
142-
})
143-
.map(([previous, next]) => next)
123+
mouseDrag
144124
.filter(({x, y}) => x !== 0 || y !== 0)
145-
.subscribe(({x, y}) => {
125+
.subscribe(({x, y, currentDrag, clientX, clientY}) => {
126+
this.setCssTransform(`translate(${x}px, ${y}px)`);
127+
currentDrag.next({
128+
clientX,
129+
clientY,
130+
dropData: this.dropData
131+
});
146132
this.dragging.next({x, y});
147133
});
148134

test/draggable.directive.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('draggable directive', () => {
205205
expect(draggableElement.style.cursor).not.to.be.ok;
206206
});
207207

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

0 commit comments

Comments
 (0)