Skip to content

Commit

Permalink
fix: set dimensions and z-index on ghost element
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Jun 6, 2018
1 parent 6e0a1a3 commit 9b5a6b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,21 @@ export class DraggableDirective implements OnInit, OnChanges, OnDestroy {
this.setElementStyles({
position: 'fixed',
top: `${rect.top}px`,
left: `${rect.left}px`
left: `${rect.left}px`,
width: `${rect.width}px`,
height: `${rect.height}px`,
zIndex: '10'
});

dragEnd$.subscribe(() => {
clone.parentElement!.removeChild(clone);
this.setElementStyles({
position: '',
top: '',
left: ''
left: '',
width: '',
height: '',
zIndex: ''
});
});
}
Expand Down
6 changes: 6 additions & 0 deletions test/draggable.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ describe('draggable directive', () => {
expect(draggableElement.style.position).to.equal('fixed');
expect(draggableElement.style.top).to.be.ok;
expect(draggableElement.style.left).to.be.ok;
expect(draggableElement.style.width).to.be.ok;
expect(draggableElement.style.height).to.be.ok;
expect(draggableElement.style.zIndex).to.equal('10');
expect(draggableElement.previousSibling).to.be.ok;
expect(
(draggableElement.previousElementSibling as HTMLElement).style.visibility
Expand All @@ -591,6 +594,9 @@ describe('draggable directive', () => {
expect(draggableElement.style.position).not.to.be.ok;
expect(draggableElement.style.top).not.to.be.ok;
expect(draggableElement.style.left).not.to.be.ok;
expect(draggableElement.style.width).not.to.be.ok;
expect(draggableElement.style.height).not.to.be.ok;
expect(draggableElement.style.zIndex).not.to.be.ok;
expect(
(draggableElement.previousElementSibling as HTMLElement).hasAttribute(
'mwldraggable'
Expand Down

0 comments on commit 9b5a6b0

Please sign in to comment.