@@ -4352,7 +4352,7 @@ describe('CdkDrag', () => {
4352
4352
expect ( list . scrollTop ) . toBeLessThan ( initialScrollDistance ) ;
4353
4353
} ) ) ;
4354
4354
4355
- it ( 'should auto-scroll right if the user holds their pointer at right edge' , fakeAsync ( ( ) => {
4355
+ it ( 'should auto-scroll right if the user holds their pointer at right edge in ltr ' , fakeAsync ( ( ) => {
4356
4356
const fixture = createComponent ( DraggableInScrollableHorizontalDropZone ) ;
4357
4357
fixture . detectChanges ( ) ;
4358
4358
const item = fixture . componentInstance . dragItems . first . element . nativeElement ;
@@ -4374,7 +4374,7 @@ describe('CdkDrag', () => {
4374
4374
expect ( list . scrollLeft ) . toBeGreaterThan ( 0 ) ;
4375
4375
} ) ) ;
4376
4376
4377
- it ( 'should auto-scroll left if the user holds their pointer at left edge' , fakeAsync ( ( ) => {
4377
+ it ( 'should auto-scroll left if the user holds their pointer at left edge in ltr ' , fakeAsync ( ( ) => {
4378
4378
const fixture = createComponent ( DraggableInScrollableHorizontalDropZone ) ;
4379
4379
fixture . detectChanges ( ) ;
4380
4380
const item = fixture . componentInstance . dragItems . first . element . nativeElement ;
@@ -4390,6 +4390,56 @@ describe('CdkDrag', () => {
4390
4390
expect ( list . scrollLeft ) . toBeLessThan ( initialScrollDistance ) ;
4391
4391
} ) ) ;
4392
4392
4393
+ it ( 'should auto-scroll right if the user holds their pointer at right edge in rtl' , fakeAsync ( ( ) => {
4394
+ const fixture = createComponent ( DraggableInScrollableHorizontalDropZone , [
4395
+ {
4396
+ provide : Directionality ,
4397
+ useValue : { value : 'rtl' , change : observableOf ( ) } ,
4398
+ } ,
4399
+ ] ) ;
4400
+ fixture . nativeElement . setAttribute ( 'dir' , 'rtl' ) ;
4401
+ fixture . detectChanges ( ) ;
4402
+ const item = fixture . componentInstance . dragItems . first . element . nativeElement ;
4403
+ const list = fixture . componentInstance . dropInstance . element . nativeElement ;
4404
+ const listRect = list . getBoundingClientRect ( ) ;
4405
+ const initialScrollDistance = ( list . scrollLeft = - list . scrollWidth ) ;
4406
+
4407
+ startDraggingViaMouse ( fixture , item ) ;
4408
+ dispatchMouseEvent (
4409
+ document ,
4410
+ 'mousemove' ,
4411
+ listRect . left + listRect . width ,
4412
+ listRect . top + listRect . height / 2 ,
4413
+ ) ;
4414
+ fixture . detectChanges ( ) ;
4415
+ tickAnimationFrames ( 20 ) ;
4416
+
4417
+ expect ( list . scrollLeft ) . toBeGreaterThan ( initialScrollDistance ) ;
4418
+ } ) ) ;
4419
+
4420
+ it ( 'should auto-scroll left if the user holds their pointer at left edge in rtl' , fakeAsync ( ( ) => {
4421
+ const fixture = createComponent ( DraggableInScrollableHorizontalDropZone , [
4422
+ {
4423
+ provide : Directionality ,
4424
+ useValue : { value : 'rtl' , change : observableOf ( ) } ,
4425
+ } ,
4426
+ ] ) ;
4427
+ fixture . nativeElement . setAttribute ( 'dir' , 'rtl' ) ;
4428
+ fixture . detectChanges ( ) ;
4429
+ const item = fixture . componentInstance . dragItems . first . element . nativeElement ;
4430
+ const list = fixture . componentInstance . dropInstance . element . nativeElement ;
4431
+ const listRect = list . getBoundingClientRect ( ) ;
4432
+
4433
+ expect ( list . scrollLeft ) . toBe ( 0 ) ;
4434
+
4435
+ startDraggingViaMouse ( fixture , item ) ;
4436
+ dispatchMouseEvent ( document , 'mousemove' , listRect . left , listRect . top + listRect . height / 2 ) ;
4437
+ fixture . detectChanges ( ) ;
4438
+ tickAnimationFrames ( 20 ) ;
4439
+
4440
+ expect ( list . scrollLeft ) . toBeLessThan ( 0 ) ;
4441
+ } ) ) ;
4442
+
4393
4443
it ( 'should be able to start auto scrolling with a drag boundary' , fakeAsync ( ( ) => {
4394
4444
const fixture = createComponent ( DraggableInScrollableHorizontalDropZone ) ;
4395
4445
fixture . componentInstance . boundarySelector = '.drop-list' ;
0 commit comments