Skip to content

Commit 4a5b254

Browse files
committed
Support copying items if the dropList has copyItems set to true
1 parent 0bd8899 commit 4a5b254

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/cdk/drag-drop/drag.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,10 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
376376
// We move the element out at the end of the body and we make it hidden, because keeping it in
377377
// place will throw off the consumer's `:last-child` selectors. We can't remove the element
378378
// from the DOM completely, because iOS will stop firing all subsequent events in the chain.
379+
if(!this._initialContainer.copyItems) {
379380
element.style.display = 'none';
380381
this._document.body.appendChild(element.parentNode!.replaceChild(placeholder, element));
382+
}
381383
this._document.body.appendChild(preview);
382384
this.dropContainer.start();
383385
}

src/cdk/drag-drop/drop-list-container.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export interface CdkDropListContainer<T = any> {
2323
/** Direction in which the list is oriented. */
2424
orientation: 'horizontal' | 'vertical';
2525

26+
/* Whether the items should be dragged out from the container or copy to target drop zone.*/
27+
copyItems: boolean;
28+
2629
/** Locks the position of the draggable elements inside the container along the specified axis. */
2730
lockAxis: 'x' | 'y';
2831

src/cdk/drag-drop/drop-list.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export class CdkDropList<T = any> implements OnInit, OnDestroy {
8484
@Input('cdkDropListEnterPredicate')
8585
enterPredicate: (drag: CdkDrag, drop: CdkDropList) => boolean = () => true
8686

87+
@Input('cdkCopyItems')
88+
copyItems: boolean = false;
89+
8790
/** Emits when the user drops an item inside the container. */
8891
@Output('cdkDropListDropped')
8992
dropped: EventEmitter<CdkDragDrop<T, any>> = new EventEmitter<CdkDragDrop<T, any>>();

0 commit comments

Comments
 (0)