@@ -1052,6 +1052,30 @@ describe('Standalone CdkDrag', () => {
10521052 expect ( dragElement . style . transform ) . toBe ( 'translate3d(100px, 100px, 0px)' ) ;
10531053 } ) ;
10541054
1055+ it ( 'should keep a touch drag within its boundary when another target is already touched' , ( ) => {
1056+ const fixture = createComponent ( StandaloneDraggable ) ;
1057+ fixture . componentInstance . boundary = '.wrapper' ;
1058+ fixture . detectChanges ( ) ;
1059+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
1060+ const rect = dragElement . getBoundingClientRect ( ) ;
1061+ const outsideTouch = { pageX : rect . left + 400 , pageY : rect . top + 400 , identifier : 0 } ;
1062+
1063+ const dispatchDragTouch = ( type : string , x : number , y : number ) => {
1064+ const event = createTouchEvent ( type , x , y ) ;
1065+ const touch = ( event as TouchEvent ) . targetTouches [ 0 ] ;
1066+ Object . defineProperty ( event , 'touches' , { get : ( ) => [ outsideTouch , touch ] } ) ;
1067+ dispatchEvent ( dragElement , event ) ;
1068+ fixture . detectChanges ( ) ;
1069+ } ;
1070+
1071+ dispatchDragTouch ( 'touchstart' , rect . left + 10 , rect . top + 10 ) ;
1072+ dispatchDragTouch ( 'touchmove' , rect . left + 310 , rect . top + 310 ) ;
1073+ dispatchDragTouch ( 'touchmove' , rect . left + 310 , rect . top + 310 ) ;
1074+ dispatchDragTouch ( 'touchend' , rect . left + 310 , rect . top + 310 ) ;
1075+
1076+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(100px, 100px, 0px)' ) ;
1077+ } ) ;
1078+
10551079 it ( 'should allow for dragging to be constrained to an element while using constrainPosition' , ( ) => {
10561080 const fixture = createComponent ( StandaloneDraggable ) ;
10571081 fixture . componentInstance . boundary = '.wrapper' ;
0 commit comments