@@ -691,13 +691,55 @@ describe('CdkDrag', () => {
691691 currentIndex : 2 ,
692692 item : firstItem ,
693693 container : fixture . componentInstance . dropInstance ,
694- previousContainer : fixture . componentInstance . dropInstance
694+ previousContainer : fixture . componentInstance . dropInstance ,
695+ isPointerOverContainer : true
695696 } ) ;
696697
697698 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
698699 . toEqual ( [ 'One' , 'Two' , 'Zero' , 'Three' ] ) ;
699700 } ) ) ;
700701
702+ it ( 'should expose whether an item was dropped over a container' , fakeAsync ( ( ) => {
703+ const fixture = createComponent ( DraggableInDropZone ) ;
704+ fixture . detectChanges ( ) ;
705+ const dragItems = fixture . componentInstance . dragItems ;
706+ const firstItem = dragItems . first ;
707+ const thirdItemRect = dragItems . toArray ( ) [ 2 ] . element . nativeElement . getBoundingClientRect ( ) ;
708+
709+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
710+ thirdItemRect . left + 1 , thirdItemRect . top + 1 ) ;
711+ flush ( ) ;
712+ fixture . detectChanges ( ) ;
713+
714+ expect ( fixture . componentInstance . droppedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
715+
716+ const event : CdkDragDrop < any > =
717+ fixture . componentInstance . droppedSpy . calls . mostRecent ( ) . args [ 0 ] ;
718+
719+ expect ( event . isPointerOverContainer ) . toBe ( true ) ;
720+ } ) ) ;
721+
722+ it ( 'should expose whether an item was dropped outside of a container' , fakeAsync ( ( ) => {
723+ const fixture = createComponent ( DraggableInDropZone ) ;
724+ fixture . detectChanges ( ) ;
725+ const dragItems = fixture . componentInstance . dragItems ;
726+ const firstItem = dragItems . first ;
727+ const containerRect = fixture . componentInstance . dropInstance . element
728+ . nativeElement . getBoundingClientRect ( ) ;
729+
730+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
731+ containerRect . right + 10 , containerRect . bottom + 10 ) ;
732+ flush ( ) ;
733+ fixture . detectChanges ( ) ;
734+
735+ expect ( fixture . componentInstance . droppedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
736+
737+ const event : CdkDragDrop < any > =
738+ fixture . componentInstance . droppedSpy . calls . mostRecent ( ) . args [ 0 ] ;
739+
740+ expect ( event . isPointerOverContainer ) . toBe ( false ) ;
741+ } ) ) ;
742+
701743 it ( 'should dispatch the `sorted` event as an item is being sorted' , fakeAsync ( ( ) => {
702744 const fixture = createComponent ( DraggableInDropZone ) ;
703745 fixture . detectChanges ( ) ;
@@ -756,7 +798,8 @@ describe('CdkDrag', () => {
756798 currentIndex : 0 ,
757799 item : firstItem ,
758800 container : fixture . componentInstance . dropInstance ,
759- previousContainer : fixture . componentInstance . dropInstance
801+ previousContainer : fixture . componentInstance . dropInstance ,
802+ isPointerOverContainer : false
760803 } ) ;
761804
762805 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -813,7 +856,8 @@ describe('CdkDrag', () => {
813856 currentIndex : 2 ,
814857 item : firstItem ,
815858 container : fixture . componentInstance . dropInstance ,
816- previousContainer : fixture . componentInstance . dropInstance
859+ previousContainer : fixture . componentInstance . dropInstance ,
860+ isPointerOverContainer : true
817861 } ) ;
818862
819863 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -852,7 +896,8 @@ describe('CdkDrag', () => {
852896 currentIndex : 2 ,
853897 item : firstItem ,
854898 container : fixture . componentInstance . dropInstance ,
855- previousContainer : fixture . componentInstance . dropInstance
899+ previousContainer : fixture . componentInstance . dropInstance ,
900+ isPointerOverContainer : true
856901 } ) ;
857902
858903 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -887,7 +932,8 @@ describe('CdkDrag', () => {
887932 currentIndex : 0 ,
888933 item : firstItem ,
889934 container : fixture . componentInstance . dropInstance ,
890- previousContainer : fixture . componentInstance . dropInstance
935+ previousContainer : fixture . componentInstance . dropInstance ,
936+ isPointerOverContainer : false
891937 } ) ;
892938
893939 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -1699,7 +1745,8 @@ describe('CdkDrag', () => {
16991745 currentIndex : 3 ,
17001746 item,
17011747 container : fixture . componentInstance . dropInstances . toArray ( ) [ 1 ] ,
1702- previousContainer : fixture . componentInstance . dropInstances . first
1748+ previousContainer : fixture . componentInstance . dropInstances . first ,
1749+ isPointerOverContainer : true
17031750 } ) ;
17041751 } ) ) ;
17051752
@@ -1800,7 +1847,8 @@ describe('CdkDrag', () => {
18001847 currentIndex : 3 ,
18011848 item : groups [ 0 ] [ 1 ] ,
18021849 container : dropInstances [ 1 ] ,
1803- previousContainer : dropInstances [ 0 ]
1850+ previousContainer : dropInstances [ 0 ] ,
1851+ isPointerOverContainer : true
18041852 } ) ;
18051853 } ) ) ;
18061854
@@ -1829,7 +1877,8 @@ describe('CdkDrag', () => {
18291877 currentIndex : 1 ,
18301878 item : groups [ 0 ] [ 1 ] ,
18311879 container : dropInstances [ 0 ] ,
1832- previousContainer : dropInstances [ 0 ]
1880+ previousContainer : dropInstances [ 0 ] ,
1881+ isPointerOverContainer : false
18331882 } ) ;
18341883 } ) ) ;
18351884
@@ -1858,7 +1907,8 @@ describe('CdkDrag', () => {
18581907 currentIndex : 1 ,
18591908 item : groups [ 0 ] [ 1 ] ,
18601909 container : dropInstances [ 0 ] ,
1861- previousContainer : dropInstances [ 0 ]
1910+ previousContainer : dropInstances [ 0 ] ,
1911+ isPointerOverContainer : false
18621912 } ) ;
18631913 } ) ) ;
18641914
@@ -1980,7 +2030,8 @@ describe('CdkDrag', () => {
19802030 currentIndex : 3 ,
19812031 item : groups [ 0 ] [ 1 ] ,
19822032 container : dropInstances [ 1 ] ,
1983- previousContainer : dropInstances [ 0 ]
2033+ previousContainer : dropInstances [ 0 ] ,
2034+ isPointerOverContainer : true
19842035 } ) ;
19852036 } ) ) ;
19862037
@@ -2005,7 +2056,8 @@ describe('CdkDrag', () => {
20052056 currentIndex : 3 ,
20062057 item : groups [ 0 ] [ 1 ] ,
20072058 container : dropInstances [ 1 ] ,
2008- previousContainer : dropInstances [ 0 ]
2059+ previousContainer : dropInstances [ 0 ] ,
2060+ isPointerOverContainer : true
20092061 } ) ;
20102062 } ) ) ;
20112063
@@ -2035,7 +2087,8 @@ describe('CdkDrag', () => {
20352087 currentIndex : 3 ,
20362088 item : groups [ 0 ] [ 1 ] ,
20372089 container : dropInstances [ 1 ] ,
2038- previousContainer : dropInstances [ 0 ]
2090+ previousContainer : dropInstances [ 0 ] ,
2091+ isPointerOverContainer : true
20392092 } ) ;
20402093 } ) ) ;
20412094
@@ -2069,7 +2122,8 @@ describe('CdkDrag', () => {
20692122 currentIndex : 0 ,
20702123 item,
20712124 container : fixture . componentInstance . dropInstances . toArray ( ) [ 1 ] ,
2072- previousContainer : fixture . componentInstance . dropInstances . first
2125+ previousContainer : fixture . componentInstance . dropInstances . first ,
2126+ isPointerOverContainer : true
20732127 } ) ;
20742128
20752129 expect ( dropContainers [ 0 ] . contains ( item . element . nativeElement ) ) . toBe ( true ,
@@ -2516,7 +2570,7 @@ function dragElementViaMouse(fixture: ComponentFixture<any>,
25162570 dispatchMouseEvent ( document , 'mousemove' , x , y ) ;
25172571 fixture . detectChanges ( ) ;
25182572
2519- dispatchMouseEvent ( document , 'mouseup' ) ;
2573+ dispatchMouseEvent ( document , 'mouseup' , x , y ) ;
25202574 fixture . detectChanges ( ) ;
25212575}
25222576
@@ -2555,7 +2609,7 @@ function dragElementViaTouch(fixture: ComponentFixture<any>,
25552609 dispatchTouchEvent ( document , 'touchmove' , x , y ) ;
25562610 fixture . detectChanges ( ) ;
25572611
2558- dispatchTouchEvent ( document , 'touchend' ) ;
2612+ dispatchTouchEvent ( document , 'touchend' , x , y ) ;
25592613 fixture . detectChanges ( ) ;
25602614}
25612615
0 commit comments