@@ -636,6 +636,19 @@ describe('CdkDrag', () => {
636
636
expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
637
637
} ) ) ;
638
638
639
+ it ( 'should be able to set an alternate drag root element for ng-container' , fakeAsync ( ( ) => {
640
+ const fixture = createComponent ( DraggableNgContainerWithAlternateRoot ) ;
641
+ fixture . detectChanges ( ) ;
642
+
643
+ const dragRoot = fixture . componentInstance . dragRoot . nativeElement ;
644
+
645
+ expect ( dragRoot . style . transform ) . toBeFalsy ( ) ;
646
+
647
+ dragElementViaMouse ( fixture , dragRoot , 50 , 100 ) ;
648
+
649
+ expect ( dragRoot . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
650
+ } ) ) ;
651
+
639
652
it ( 'should preserve the initial transform if the root element changes' , fakeAsync ( ( ) => {
640
653
const fixture = createComponent ( DraggableWithAlternateRoot ) ;
641
654
fixture . detectChanges ( ) ;
@@ -7150,6 +7163,21 @@ class DraggableWithRadioInputsInDropZone {
7150
7163
] ;
7151
7164
}
7152
7165
7166
+
7167
+ @Component ( {
7168
+ template : `
7169
+ <div #dragRoot class="alternate-root" style="width: 200px; height: 200px; background: hotpink">
7170
+ <ng-container cdkDrag cdkDragRootElement=".alternate-root">
7171
+ <div style="width: 100px; height: 100px; background: red;"></div>
7172
+ </ng-container>
7173
+ </div>
7174
+ `
7175
+ } )
7176
+ class DraggableNgContainerWithAlternateRoot {
7177
+ @ViewChild ( 'dragRoot' ) dragRoot : ElementRef < HTMLElement > ;
7178
+ @ViewChild ( CdkDrag ) dragInstance : CdkDrag ;
7179
+ }
7180
+
7153
7181
/**
7154
7182
* Drags an element to a position on the page using the mouse.
7155
7183
* @param fixture Fixture on which to run change detection.
0 commit comments