File tree Expand file tree Collapse file tree 4 files changed +43
-7
lines changed
projects/igniteui-angular/src/lib/carousel Expand file tree Collapse file tree 4 files changed +43
-7
lines changed Original file line number Diff line number Diff line change 33All notable changes for each version of this project will be documented in this file.
44
55## 20.1.0
6+ ### New Features
7+ - ` IgxCarousel `
8+ - Added ` select ` method overload accepting index.
9+ ``` ts
10+ this .carousel .select (2 , Direction .NEXT );
11+ ```
12+
613### General
714- ` IgxDropDown ` now exposes a ` role ` input property , allowing users to customize the role attribute based on the use case . The default is ` listbox ` .
815
16+
917## 20.0 .6
1018### General
1119- ` IgxSimpleCombo `
Original file line number Diff line number Diff line change @@ -34,8 +34,9 @@ A walkthrough of how to get started can be found [here](https://www.infragistics
3434| ` next() ` | void | Switches to the next slide. Emits ` slideChanged ` event. |
3535| ` add(slide: IgxSlide) ` | void | Adds a slide to the carousel. Emits ` slideAdded ` event. |
3636| ` remove(slide: IgxSlide) ` | void | Removes an existing slide from the carousel. Emits ` slideRemoved ` event. |
37- | ` get(index: Number) ` | IgxSlide or void | Returns the slide with the given index or null. |
38- | ` select(slide: IgxSlide, direction: Direction) ` | void | Selects the slide and the direction to transition to. Emits ` slideChanged ` event. |
37+ | ` get(index: number) ` | IgxSlide or void | Returns the slide with the given index or null. |
38+ | ` select(slide: IgxSlide, direction: Direction) ` | void | Switches to the passed-in slide with a given direction. Emits ` slideChanged ` event. |
39+ | ` select(index: number, direction: Direction) ` | void | Switches to slide by index with a given direction. Emits ` slideChanged ` event. |
3940
4041### Keyboard navigation
4142
Original file line number Diff line number Diff line change @@ -143,15 +143,27 @@ describe('Carousel', () => {
143143
144144 carousel . next ( ) ;
145145 let currentSlide = carousel . get ( carousel . current ) ;
146-
147146 fixture . detectChanges ( ) ;
148147 expect ( carousel . get ( 1 ) ) . toBe ( currentSlide ) ;
149148
150149 currentSlide = carousel . get ( 0 ) ;
151150 carousel . prev ( ) ;
152-
153151 fixture . detectChanges ( ) ;
154152 expect ( carousel . get ( 0 ) ) . toBe ( currentSlide ) ;
153+
154+ carousel . select ( 1 ) ;
155+ fixture . detectChanges ( ) ;
156+ expect ( carousel . get ( 1 ) ) . toBe ( carousel . get ( carousel . current ) ) ;
157+
158+ // select a negative index -> active slide remains the same
159+ carousel . select ( - 1 ) ;
160+ fixture . detectChanges ( ) ;
161+ expect ( carousel . get ( 1 ) ) . toBe ( carousel . get ( carousel . current ) ) ;
162+
163+ // select a non-existent index -> active slide remains the same
164+ carousel . select ( carousel . slides . length ) ;
165+ fixture . detectChanges ( ) ;
166+ expect ( carousel . get ( 1 ) ) . toBe ( carousel . get ( carousel . current ) ) ;
155167 } ) ;
156168
157169 it ( 'emit events' , ( ) => {
Original file line number Diff line number Diff line change @@ -816,14 +816,29 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
816816 }
817817
818818 /**
819- * Kicks in a transition for a given slide with a given `direction`.
819+ * Switches to the passed-in slide with a given `direction`.
820820 * ```typescript
821- * this.carousel.select(this.carousel.get(2), Direction.NEXT);
821+ * const slide = this.carousel.get(2);
822+ * this.carousel.select(slide, Direction.NEXT);
822823 * ```
823824 *
824825 * @memberOf IgxCarouselComponent
825826 */
826- public select ( slide : IgxSlideComponent , direction : Direction = Direction . NONE ) {
827+ public select ( slide : IgxSlideComponent , direction ?: Direction ) : void ;
828+ /**
829+ * Switches to slide by index with a given `direction`.
830+ * ```typescript
831+ * this.carousel.select(2, Direction.NEXT);
832+ * ```
833+ *
834+ * @memberOf IgxCarouselComponent
835+ */
836+ public select ( index : number , direction ?: Direction ) : void ;
837+ public select ( slideOrIndex : IgxSlideComponent | number , direction : Direction = Direction . NONE ) : void {
838+ const slide = typeof slideOrIndex === 'number'
839+ ? this . get ( slideOrIndex )
840+ : slideOrIndex ;
841+
827842 if ( slide && slide !== this . currentItem ) {
828843 slide . direction = direction ;
829844 slide . active = true ;
You can’t perform that action at this time.
0 commit comments