@@ -765,13 +765,55 @@ describe('CdkDrag', () => {
765765 currentIndex : 2 ,
766766 item : firstItem ,
767767 container : fixture . componentInstance . dropInstance ,
768- previousContainer : fixture . componentInstance . dropInstance
768+ previousContainer : fixture . componentInstance . dropInstance ,
769+ isPointerOverContainer : true
769770 } ) ;
770771
771772 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
772773 . toEqual ( [ 'One' , 'Two' , 'Zero' , 'Three' ] ) ;
773774 } ) ) ;
774775
776+ it ( 'should expose whether an item was dropped over a container' , fakeAsync ( ( ) => {
777+ const fixture = createComponent ( DraggableInDropZone ) ;
778+ fixture . detectChanges ( ) ;
779+ const dragItems = fixture . componentInstance . dragItems ;
780+ const firstItem = dragItems . first ;
781+ const thirdItemRect = dragItems . toArray ( ) [ 2 ] . element . nativeElement . getBoundingClientRect ( ) ;
782+
783+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
784+ thirdItemRect . left + 1 , thirdItemRect . top + 1 ) ;
785+ flush ( ) ;
786+ fixture . detectChanges ( ) ;
787+
788+ expect ( fixture . componentInstance . droppedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
789+
790+ const event : CdkDragDrop < any > =
791+ fixture . componentInstance . droppedSpy . calls . mostRecent ( ) . args [ 0 ] ;
792+
793+ expect ( event . isPointerOverContainer ) . toBe ( true ) ;
794+ } ) ) ;
795+
796+ it ( 'should expose whether an item was dropped outside of a container' , fakeAsync ( ( ) => {
797+ const fixture = createComponent ( DraggableInDropZone ) ;
798+ fixture . detectChanges ( ) ;
799+ const dragItems = fixture . componentInstance . dragItems ;
800+ const firstItem = dragItems . first ;
801+ const containerRect = fixture . componentInstance . dropInstance . element
802+ . nativeElement . getBoundingClientRect ( ) ;
803+
804+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
805+ containerRect . right + 10 , containerRect . bottom + 10 ) ;
806+ flush ( ) ;
807+ fixture . detectChanges ( ) ;
808+
809+ expect ( fixture . componentInstance . droppedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
810+
811+ const event : CdkDragDrop < any > =
812+ fixture . componentInstance . droppedSpy . calls . mostRecent ( ) . args [ 0 ] ;
813+
814+ expect ( event . isPointerOverContainer ) . toBe ( false ) ;
815+ } ) ) ;
816+
775817 it ( 'should dispatch the `sorted` event as an item is being sorted' , fakeAsync ( ( ) => {
776818 const fixture = createComponent ( DraggableInDropZone ) ;
777819 fixture . detectChanges ( ) ;
@@ -830,7 +872,8 @@ describe('CdkDrag', () => {
830872 currentIndex : 0 ,
831873 item : firstItem ,
832874 container : fixture . componentInstance . dropInstance ,
833- previousContainer : fixture . componentInstance . dropInstance
875+ previousContainer : fixture . componentInstance . dropInstance ,
876+ isPointerOverContainer : false
834877 } ) ;
835878
836879 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -887,7 +930,8 @@ describe('CdkDrag', () => {
887930 currentIndex : 2 ,
888931 item : firstItem ,
889932 container : fixture . componentInstance . dropInstance ,
890- previousContainer : fixture . componentInstance . dropInstance
933+ previousContainer : fixture . componentInstance . dropInstance ,
934+ isPointerOverContainer : true
891935 } ) ;
892936
893937 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -926,7 +970,8 @@ describe('CdkDrag', () => {
926970 currentIndex : 2 ,
927971 item : firstItem ,
928972 container : fixture . componentInstance . dropInstance ,
929- previousContainer : fixture . componentInstance . dropInstance
973+ previousContainer : fixture . componentInstance . dropInstance ,
974+ isPointerOverContainer : true
930975 } ) ;
931976
932977 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -961,7 +1006,8 @@ describe('CdkDrag', () => {
9611006 currentIndex : 0 ,
9621007 item : firstItem ,
9631008 container : fixture . componentInstance . dropInstance ,
964- previousContainer : fixture . componentInstance . dropInstance
1009+ previousContainer : fixture . componentInstance . dropInstance ,
1010+ isPointerOverContainer : false
9651011 } ) ;
9661012
9671013 expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
@@ -1797,7 +1843,8 @@ describe('CdkDrag', () => {
17971843 currentIndex : 3 ,
17981844 item,
17991845 container : fixture . componentInstance . dropInstances . toArray ( ) [ 1 ] ,
1800- previousContainer : fixture . componentInstance . dropInstances . first
1846+ previousContainer : fixture . componentInstance . dropInstances . first ,
1847+ isPointerOverContainer : true
18011848 } ) ;
18021849 } ) ) ;
18031850
@@ -1898,7 +1945,8 @@ describe('CdkDrag', () => {
18981945 currentIndex : 3 ,
18991946 item : groups [ 0 ] [ 1 ] ,
19001947 container : dropInstances [ 1 ] ,
1901- previousContainer : dropInstances [ 0 ]
1948+ previousContainer : dropInstances [ 0 ] ,
1949+ isPointerOverContainer : true
19021950 } ) ;
19031951 } ) ) ;
19041952
@@ -1927,7 +1975,8 @@ describe('CdkDrag', () => {
19271975 currentIndex : 1 ,
19281976 item : groups [ 0 ] [ 1 ] ,
19291977 container : dropInstances [ 0 ] ,
1930- previousContainer : dropInstances [ 0 ]
1978+ previousContainer : dropInstances [ 0 ] ,
1979+ isPointerOverContainer : false
19311980 } ) ;
19321981 } ) ) ;
19331982
@@ -1956,7 +2005,8 @@ describe('CdkDrag', () => {
19562005 currentIndex : 1 ,
19572006 item : groups [ 0 ] [ 1 ] ,
19582007 container : dropInstances [ 0 ] ,
1959- previousContainer : dropInstances [ 0 ]
2008+ previousContainer : dropInstances [ 0 ] ,
2009+ isPointerOverContainer : false
19602010 } ) ;
19612011 } ) ) ;
19622012
@@ -2078,7 +2128,8 @@ describe('CdkDrag', () => {
20782128 currentIndex : 3 ,
20792129 item : groups [ 0 ] [ 1 ] ,
20802130 container : dropInstances [ 1 ] ,
2081- previousContainer : dropInstances [ 0 ]
2131+ previousContainer : dropInstances [ 0 ] ,
2132+ isPointerOverContainer : true
20822133 } ) ;
20832134 } ) ) ;
20842135
@@ -2103,7 +2154,8 @@ describe('CdkDrag', () => {
21032154 currentIndex : 3 ,
21042155 item : groups [ 0 ] [ 1 ] ,
21052156 container : dropInstances [ 1 ] ,
2106- previousContainer : dropInstances [ 0 ]
2157+ previousContainer : dropInstances [ 0 ] ,
2158+ isPointerOverContainer : true
21072159 } ) ;
21082160 } ) ) ;
21092161
@@ -2133,7 +2185,8 @@ describe('CdkDrag', () => {
21332185 currentIndex : 3 ,
21342186 item : groups [ 0 ] [ 1 ] ,
21352187 container : dropInstances [ 1 ] ,
2136- previousContainer : dropInstances [ 0 ]
2188+ previousContainer : dropInstances [ 0 ] ,
2189+ isPointerOverContainer : true
21372190 } ) ;
21382191 } ) ) ;
21392192
@@ -2167,7 +2220,8 @@ describe('CdkDrag', () => {
21672220 currentIndex : 0 ,
21682221 item,
21692222 container : fixture . componentInstance . dropInstances . toArray ( ) [ 1 ] ,
2170- previousContainer : fixture . componentInstance . dropInstances . first
2223+ previousContainer : fixture . componentInstance . dropInstances . first ,
2224+ isPointerOverContainer : true
21712225 } ) ;
21722226
21732227 expect ( dropContainers [ 0 ] . contains ( item . element . nativeElement ) ) . toBe ( true ,
@@ -2656,7 +2710,7 @@ function dragElementViaMouse(fixture: ComponentFixture<any>,
26562710 dispatchMouseEvent ( document , 'mousemove' , x , y ) ;
26572711 fixture . detectChanges ( ) ;
26582712
2659- dispatchMouseEvent ( document , 'mouseup' ) ;
2713+ dispatchMouseEvent ( document , 'mouseup' , x , y ) ;
26602714 fixture . detectChanges ( ) ;
26612715}
26622716
@@ -2695,7 +2749,7 @@ function dragElementViaTouch(fixture: ComponentFixture<any>,
26952749 dispatchTouchEvent ( document , 'touchmove' , x , y ) ;
26962750 fixture . detectChanges ( ) ;
26972751
2698- dispatchTouchEvent ( document , 'touchend' ) ;
2752+ dispatchTouchEvent ( document , 'touchend' , x , y ) ;
26992753 fixture . detectChanges ( ) ;
27002754}
27012755
0 commit comments