Skip to content

Commit 9b5a6b0

Browse files
committed
fix: set dimensions and z-index on ghost element
1 parent 6e0a1a3 commit 9b5a6b0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/draggable.directive.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,21 @@ export class DraggableDirective implements OnInit, OnChanges, OnDestroy {
228228
this.setElementStyles({
229229
position: 'fixed',
230230
top: `${rect.top}px`,
231-
left: `${rect.left}px`
231+
left: `${rect.left}px`,
232+
width: `${rect.width}px`,
233+
height: `${rect.height}px`,
234+
zIndex: '10'
232235
});
233236

234237
dragEnd$.subscribe(() => {
235238
clone.parentElement!.removeChild(clone);
236239
this.setElementStyles({
237240
position: '',
238241
top: '',
239-
left: ''
242+
left: '',
243+
width: '',
244+
height: '',
245+
zIndex: ''
240246
});
241247
});
242248
}

test/draggable.directive.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ describe('draggable directive', () => {
578578
expect(draggableElement.style.position).to.equal('fixed');
579579
expect(draggableElement.style.top).to.be.ok;
580580
expect(draggableElement.style.left).to.be.ok;
581+
expect(draggableElement.style.width).to.be.ok;
582+
expect(draggableElement.style.height).to.be.ok;
583+
expect(draggableElement.style.zIndex).to.equal('10');
581584
expect(draggableElement.previousSibling).to.be.ok;
582585
expect(
583586
(draggableElement.previousElementSibling as HTMLElement).style.visibility
@@ -591,6 +594,9 @@ describe('draggable directive', () => {
591594
expect(draggableElement.style.position).not.to.be.ok;
592595
expect(draggableElement.style.top).not.to.be.ok;
593596
expect(draggableElement.style.left).not.to.be.ok;
597+
expect(draggableElement.style.width).not.to.be.ok;
598+
expect(draggableElement.style.height).not.to.be.ok;
599+
expect(draggableElement.style.zIndex).not.to.be.ok;
594600
expect(
595601
(draggableElement.previousElementSibling as HTMLElement).hasAttribute(
596602
'mwldraggable'

0 commit comments

Comments
 (0)