File tree Expand file tree Collapse file tree 3 files changed +40
-5
lines changed
projects/igniteui-angular/src/lib/carousel Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes for each version of this project will be documented in this file.
4
4
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
+
5
13
## 20.0 .2
6
14
7
15
### New Features
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