@@ -594,6 +594,44 @@ describe('List', () => {
594
594
expect ( rightPanTmpl . nativeElement . style . visibility ) . toBe ( 'hidden' ) ;
595
595
} ) ) ;
596
596
597
+ it ( 'cancel left panning' , fakeAsync ( ( ) => {
598
+ const fixture = TestBed . createComponent ( ListWithPanningTemplatesComponent ) ;
599
+ const list = fixture . componentInstance . list ;
600
+ fixture . detectChanges ( ) ;
601
+
602
+ const firstItem = list . items [ 0 ] as IgxListItemComponent ;
603
+ const leftPanTmpl = firstItem . leftPanningTemplateElement ;
604
+ const rightPanTmpl = firstItem . rightPanningTemplateElement ;
605
+ const itemNativeElements = fixture . debugElement . queryAll ( By . css ( 'igx-list-item' ) ) ;
606
+
607
+ /* Pan item left */
608
+ cancelItemPanning ( itemNativeElements [ 1 ] , - 2 , - 8 ) ;
609
+ tick ( 600 ) ;
610
+
611
+ expect ( firstItem . panState ) . toBe ( IgxListPanState . NONE ) ;
612
+ expect ( leftPanTmpl . nativeElement . style . visibility ) . toBe ( 'hidden' ) ;
613
+ expect ( rightPanTmpl . nativeElement . style . visibility ) . toBe ( 'hidden' ) ;
614
+ } ) ) ;
615
+
616
+ it ( 'cancel right panning' , fakeAsync ( ( ) => {
617
+ const fixture = TestBed . createComponent ( ListWithPanningTemplatesComponent ) ;
618
+ const list = fixture . componentInstance . list ;
619
+ fixture . detectChanges ( ) ;
620
+
621
+ const firstItem = list . items [ 0 ] as IgxListItemComponent ;
622
+ const leftPanTmpl = firstItem . leftPanningTemplateElement ;
623
+ const rightPanTmpl = firstItem . rightPanningTemplateElement ;
624
+ const itemNativeElements = fixture . debugElement . queryAll ( By . css ( 'igx-list-item' ) ) ;
625
+
626
+ /* Pan item right */
627
+ cancelItemPanning ( itemNativeElements [ 1 ] , 2 , 8 ) ;
628
+ tick ( 600 ) ;
629
+
630
+ expect ( firstItem . panState ) . toBe ( IgxListPanState . NONE ) ;
631
+ expect ( leftPanTmpl . nativeElement . style . visibility ) . toBe ( 'hidden' ) ;
632
+ expect ( rightPanTmpl . nativeElement . style . visibility ) . toBe ( 'hidden' ) ;
633
+ } ) ) ;
634
+
597
635
it ( 'checking the header list item does not have panning and content containers.' , ( ) => {
598
636
const fixture = TestBed . createComponent ( ListWithPanningTemplatesComponent ) ;
599
637
const list = fixture . componentInstance . list ;
@@ -818,6 +856,19 @@ describe('List', () => {
818
856
} ) ;
819
857
} ;
820
858
859
+ const cancelItemPanning = ( itemNativeElement , factorX , factorY ) => {
860
+ itemNativeElement . triggerEventHandler ( 'panstart' , {
861
+ deltaX : factorX
862
+ } ) ;
863
+ itemNativeElement . triggerEventHandler ( 'panmove' , {
864
+ deltaX : factorX ,
865
+ deltaY : factorY ,
866
+ additionalEvent : 'panup'
867
+ } ) ;
868
+
869
+ itemNativeElement . triggerEventHandler ( 'pancancel' , null ) ;
870
+ } ;
871
+
821
872
const clickItem = ( currentItem : IgxListItemComponent ) => Promise . resolve ( currentItem . element . click ( ) ) ;
822
873
823
874
const verifyItemsCount = ( list , expectedCount ) => {
0 commit comments