@@ -27,6 +27,7 @@ import {DragDropRegistry} from './drag-drop-registry';
2727import { CdkDragDrop , CdkDragEnter , CdkDragExit } from './drag-events' ;
2828import { moveItemInArray } from './drag-utils' ;
2929import { CDK_DROP_LIST_CONTAINER } from './drop-list-container' ;
30+ import { CdkDropListGroup } from './drop-list-group' ;
3031
3132
3233/** Counter used to generate unique ids for drop zones. */
@@ -143,14 +144,23 @@ export class CdkDropList<T = any> implements OnInit, OnDestroy {
143144 public element : ElementRef < HTMLElement > ,
144145 private _dragDropRegistry : DragDropRegistry < CdkDrag , CdkDropList < T > > ,
145146 private _changeDetectorRef : ChangeDetectorRef ,
146- @Optional ( ) private _dir ?: Directionality ) { }
147+ @Optional ( ) private _dir ?: Directionality ,
148+ @Optional ( ) private _group ?: CdkDropListGroup < CdkDropList > ) { }
147149
148150 ngOnInit ( ) {
149151 this . _dragDropRegistry . registerDropContainer ( this ) ;
152+
153+ if ( this . _group ) {
154+ this . _group . _items . add ( this ) ;
155+ }
150156 }
151157
152158 ngOnDestroy ( ) {
153159 this . _dragDropRegistry . removeDropContainer ( this ) ;
160+
161+ if ( this . _group ) {
162+ this . _group . _items . delete ( this ) ;
163+ }
154164 }
155165
156166 /** Whether an item in the container is being dragged. */
@@ -366,6 +376,8 @@ export class CdkDropList<T = any> implements OnInit, OnDestroy {
366376 /** Refreshes the position cache of the items and sibling containers. */
367377 private _cachePositions ( ) {
368378 const isHorizontal = this . orientation === 'horizontal' ;
379+
380+ this . _positionCache . self = this . element . nativeElement . getBoundingClientRect ( ) ;
369381 this . _positionCache . items = this . _activeDraggables
370382 . map ( drag => {
371383 const elementToMeasure = this . _dragDropRegistry . isDragging ( drag ) ?
@@ -397,12 +409,10 @@ export class CdkDropList<T = any> implements OnInit, OnDestroy {
397409 a . clientRect . top - b . clientRect . top ;
398410 } ) ;
399411
400- this . _positionCache . siblings = coerceArray ( this . connectedTo )
401- . map ( drop => typeof drop === 'string' ? this . _dragDropRegistry . getDropContainer ( drop ) ! : drop )
402- . filter ( drop => drop && drop !== this )
403- . map ( drop => ( { drop, clientRect : drop . element . nativeElement . getBoundingClientRect ( ) } ) ) ;
404-
405- this . _positionCache . self = this . element . nativeElement . getBoundingClientRect ( ) ;
412+ this . _positionCache . siblings = this . _getConnectedLists ( ) . map ( drop => ( {
413+ drop,
414+ clientRect : drop . element . nativeElement . getBoundingClientRect ( )
415+ } ) ) ;
406416 }
407417
408418 /** Resets the container to its initial state. */
@@ -535,6 +545,23 @@ export class CdkDropList<T = any> implements OnInit, OnDestroy {
535545
536546 return siblingOffset ;
537547 }
548+
549+ /** Gets an array of unique drop lists that the current list is connected to. */
550+ private _getConnectedLists ( ) : CdkDropList [ ] {
551+ const siblings = coerceArray ( this . connectedTo ) . map ( drop => {
552+ return typeof drop === 'string' ? this . _dragDropRegistry . getDropContainer ( drop ) ! : drop ;
553+ } ) ;
554+
555+ if ( this . _group ) {
556+ this . _group . _items . forEach ( drop => {
557+ if ( siblings . indexOf ( drop ) === - 1 ) {
558+ siblings . push ( drop ) ;
559+ }
560+ } ) ;
561+ }
562+
563+ return siblings . filter ( drop => drop && drop !== this ) ;
564+ }
538565}
539566
540567
0 commit comments