@@ -96,15 +96,6 @@ export class CarouselHammerConfig extends HammerGestureConfig {
9696} )
9797
9898export class IgxCarouselComponent implements OnDestroy , AfterContentInit {
99- /**
100- * Returns the `role` attribute of the carousel.
101- * ```typescript
102- * let carouselRole = this.carousel.role;
103- * ```
104- *
105- * @memberof IgxCarouselComponent
106- */
107- @HostBinding ( 'attr.role' ) public role = 'region' ;
10899
109100 /**
110101 * Sets the `id` of the carousel.
@@ -118,29 +109,24 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
118109 @HostBinding ( 'attr.id' )
119110 @Input ( )
120111 public id = `igx-carousel-${ NEXT_ID ++ } ` ;
121-
122112 /**
123- * Returns the `aria-label` of the carousel.
124- *
125- * ```typescript
126- * let carousel = this.carousel.ariaLabel;
127- * ```
128- *
129- */
130- @HostBinding ( 'attr.aria-label' )
131- public ariaLabel = 'carousel' ;
132-
133- /**
134- * Returns the `tabIndex` of the carousel component.
113+ * Returns the `role` attribute of the carousel.
135114 * ```typescript
136- * let tabIndex = this.carousel.tabIndex ;
115+ * let carouselRole = this.carousel.role ;
137116 * ```
138117 *
139118 * @memberof IgxCarouselComponent
140119 */
141- @HostBinding ( 'attr.tabindex' )
142- get tabIndex ( ) {
143- return 0 ;
120+ @HostBinding ( 'attr.role' ) public role = 'region' ;
121+
122+ /** @hidden */
123+ @HostBinding ( 'attr.aria-roledescription' )
124+ public roleDescription = 'carousel' ;
125+
126+ /** @hidden */
127+ @HostBinding ( 'attr.aria-labelledby' )
128+ public get labelId ( ) {
129+ return this . showIndicatorsLabel ? `${ this . id } -label` : null ;
144130 }
145131
146132 /**
@@ -161,7 +147,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
161147 * ```
162148 */
163149 @HostBinding ( 'style.touch-action' )
164- get touchAction ( ) {
150+ public get touchAction ( ) {
165151 return this . gesturesSupport ? 'pan-y' : 'auto' ;
166152 }
167153
@@ -398,11 +384,15 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
398384 @ViewChild ( 'defaultPrevButton' , { read : TemplateRef , static : true } )
399385 private defaultPrevButton : TemplateRef < any > ;
400386
387+ /**
388+ * @hidden
389+ * @internal
390+ */
391+ public stoppedByInteraction : boolean ;
401392 private _interval : number ;
402393 private _resourceStrings = CurrentResourceStrings . CarouselResStrings ;
403394 private lastInterval : any ;
404395 private playing : boolean ;
405- private stoppedByInteraction : boolean ;
406396 private destroyed : boolean ;
407397 private destroy$ = new Subject < any > ( ) ;
408398 private differ : IterableDiffer < IgxSlideComponent > | null = null ;
@@ -420,14 +410,14 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
420410 * By default it uses EN resources.
421411 */
422412 @Input ( )
423- set resourceStrings ( value : ICarouselResourceStrings ) {
413+ public set resourceStrings ( value : ICarouselResourceStrings ) {
424414 this . _resourceStrings = Object . assign ( { } , this . _resourceStrings , value ) ;
425415 }
426416
427417 /**
428418 * An accessor that returns the resource strings.
429419 */
430- get resourceStrings ( ) : ICarouselResourceStrings {
420+ public get resourceStrings ( ) : ICarouselResourceStrings {
431421 return this . _resourceStrings ;
432422 }
433423
@@ -484,7 +474,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
484474 * @memberOf IgxCarouselComponent
485475 */
486476 public get total ( ) : number {
487- return this . slides . length ;
477+ return this . slides ? .length ;
488478 }
489479
490480 /**
@@ -530,7 +520,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
530520 *
531521 * @memberof IgxCarouselComponent
532522 */
533- get nativeElement ( ) : any {
523+ public get nativeElement ( ) : any {
534524 return this . element . nativeElement ;
535525 }
536526
@@ -543,7 +533,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
543533 * @memberof IgxCarouselComponent
544534 */
545535 @Input ( )
546- get interval ( ) : number {
536+ public get interval ( ) : number {
547537 return this . _interval ;
548538 }
549539
@@ -556,7 +546,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
556546 *
557547 * @memberof IgxCarouselComponent
558548 */
559- set interval ( value : number ) {
549+ public set interval ( value : number ) {
560550 this . _interval = + value ;
561551 this . restartInterval ( ) ;
562552 }
@@ -566,13 +556,14 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
566556 this . differ = this . iterableDiffers . find ( [ ] ) . create ( null ) ;
567557 }
568558
559+
569560 /** @hidden */
570561 @HostListener ( 'keydown.arrowright' , [ '$event' ] )
571562 public onKeydownArrowRight ( event ) {
572563 if ( this . keyboardSupport ) {
573564 event . preventDefault ( ) ;
574565 this . next ( ) ;
575- requestAnimationFrame ( ( ) => this . nativeElement . focus ( ) ) ;
566+ requestAnimationFrame ( ( ) => this . slides . find ( s => s . active ) . nativeElement . focus ( ) ) ;
576567 }
577568 }
578569
@@ -582,7 +573,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
582573 if ( this . keyboardSupport ) {
583574 event . preventDefault ( ) ;
584575 this . prev ( ) ;
585- requestAnimationFrame ( ( ) => this . nativeElement . focus ( ) ) ;
576+ requestAnimationFrame ( ( ) => this . slides . find ( s => s . active ) . nativeElement . focus ( ) ) ;
586577 }
587578 }
588579
@@ -608,7 +599,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
608599 if ( this . keyboardSupport && this . slides . length > 0 ) {
609600 event . preventDefault ( ) ;
610601 this . slides . first . active = true ;
611- requestAnimationFrame ( ( ) => this . nativeElement . focus ( ) ) ;
602+ requestAnimationFrame ( ( ) => this . slides . find ( s => s . active ) . nativeElement . focus ( ) ) ;
612603 }
613604 }
614605
@@ -618,7 +609,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
618609 if ( this . keyboardSupport && this . slides . length > 0 ) {
619610 event . preventDefault ( ) ;
620611 this . slides . last . active = true ;
621- requestAnimationFrame ( ( ) => this . nativeElement . focus ( ) ) ;
612+ requestAnimationFrame ( ( ) => this . slides . find ( s => s . active ) . nativeElement . focus ( ) ) ;
622613 }
623614 }
624615
@@ -713,11 +704,6 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
713704 }
714705 }
715706
716- /** @hidden */
717- public setAriaLabel ( slide ) {
718- return `Item ${ slide . index + 1 } of ${ this . total } ` ;
719- }
720-
721707 /**
722708 * Returns the slide corresponding to the provided `index` or null.
723709 * ```typescript
@@ -1104,6 +1090,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
11041090 this . slides . reduce ( ( any , c , ind ) => c . index = ind , 0 ) ; // reset slides indexes
11051091 diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxSlideComponent > ) => {
11061092 const slide = record . item ;
1093+ slide . total = this . total ;
11071094 this . onSlideAdded . emit ( { carousel : this , slide } ) ;
11081095 if ( slide . active ) {
11091096 this . currentSlide = slide ;
0 commit comments