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 3
3
All notable changes for each version of this project will be documented in this file.
4
4
5
5
## 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
+
6
13
### General
7
14
- ` IgxDropDown ` now exposes a ` role ` input property , allowing users to customize the role attribute based on the use case . The default is ` listbox ` .
8
15
16
+
9
17
## 20.0 .6
10
18
### General
11
19
- ` 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
34
34
| ` next() ` | void | Switches to the next slide. Emits ` slideChanged ` event. |
35
35
| ` add(slide: IgxSlide) ` | void | Adds a slide to the carousel. Emits ` slideAdded ` event. |
36
36
| ` 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. |
39
40
40
41
### Keyboard navigation
41
42
Original file line number Diff line number Diff line change @@ -143,15 +143,27 @@ describe('Carousel', () => {
143
143
144
144
carousel . next ( ) ;
145
145
let currentSlide = carousel . get ( carousel . current ) ;
146
-
147
146
fixture . detectChanges ( ) ;
148
147
expect ( carousel . get ( 1 ) ) . toBe ( currentSlide ) ;
149
148
150
149
currentSlide = carousel . get ( 0 ) ;
151
150
carousel . prev ( ) ;
152
-
153
151
fixture . detectChanges ( ) ;
154
152
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 ) ) ;
155
167
} ) ;
156
168
157
169
it ( 'emit events' , ( ) => {
Original file line number Diff line number Diff line change @@ -816,14 +816,29 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
816
816
}
817
817
818
818
/**
819
- * Kicks in a transition for a given slide with a given `direction`.
819
+ * Switches to the passed-in slide with a given `direction`.
820
820
* ```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);
822
823
* ```
823
824
*
824
825
* @memberOf IgxCarouselComponent
825
826
*/
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
+
827
842
if ( slide && slide !== this . currentItem ) {
828
843
slide . direction = direction ;
829
844
slide . active = true ;
You can’t perform that action at this time.
0 commit comments