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