Skip to content

Commit f51214e

Browse files
committed
feat(ghostElementAppendTo): allow the ghost element parent to be customised
1 parent 388b860 commit f51214e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/draggable.directive.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ export class DraggableDirective implements OnInit, OnChanges, OnDestroy {
9090
*/
9191
@Input() dragActiveClass: string;
9292

93+
/**
94+
* The element the ghost element will be appended to. Default is document.body
95+
*/
96+
@Input() ghostElementAppendTo: HTMLElement;
97+
9398
/**
9499
* Called when the element can be dragged along one axis and has the mouse or pointer device pressed on it
95100
*/
@@ -239,7 +244,9 @@ export class DraggableDirective implements OnInit, OnChanges, OnDestroy {
239244
'visibility',
240245
'hidden'
241246
);
242-
this.document.body.appendChild(clone);
247+
const appendToElement =
248+
this.ghostElementAppendTo || this.document.body;
249+
appendToElement.appendChild(clone);
243250
this.ghostElement = clone;
244251

245252
this.setElementStyles(clone, {

0 commit comments

Comments
 (0)