Skip to content

Commit c41fd9c

Browse files
Merge pull request #15240 from IgniteUI/rivanova/fix-15020-18.2.x
fix(carousel): inject interface in slide ctor
2 parents fcc9941 + c95bea0 commit c41fd9c

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

projects/igniteui-angular/src/lib/carousel/carousel-base.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { AnimationReferenceMetadata, useAnimation } from '@angular/animations';
2-
import { ChangeDetectorRef, EventEmitter, Inject } from '@angular/core';
2+
import { ChangeDetectorRef, EventEmitter, Inject, InjectionToken } from '@angular/core';
33
import { IgxAngularAnimationService } from '../services/animation/angular-animation-service';
44
import { AnimationPlayer, AnimationService } from '../services/animation/animation';
55
import { fadeIn, slideInLeft } from 'igniteui-angular/animations';
6-
import { CarouselAnimationType } from './enums';
6+
import { CarouselAnimationType, CarouselIndicatorsOrientation } from './enums';
77

88
export enum Direction { NONE, NEXT, PREV }
99

@@ -12,6 +12,37 @@ export interface CarouselAnimationSettings {
1212
leaveAnimation: AnimationReferenceMetadata;
1313
}
1414

15+
export interface ICarouselComponentBase {
16+
id: string;
17+
role: string;
18+
cssClass: string;
19+
loop: boolean;
20+
pause: boolean;
21+
navigation: boolean;
22+
indicators: boolean;
23+
vertical: boolean;
24+
keyboardSupport: boolean;
25+
gesturesSupport: boolean;
26+
maximumIndicatorsCount: number;
27+
indicatorsOrientation: CarouselIndicatorsOrientation;
28+
animationType: CarouselAnimationType;
29+
total: number;
30+
current: number;
31+
interval: number;
32+
slideChanged: EventEmitter<any>;
33+
slideAdded: EventEmitter<any>;
34+
slideRemoved: EventEmitter<any>;
35+
carouselPaused: EventEmitter<any>;
36+
carouselPlaying: EventEmitter<any>;
37+
next(): void;
38+
prev(): void;
39+
play(): void;
40+
stop(): void
41+
}
42+
43+
/** @hidden */
44+
export const IGX_CAROUSEL_COMPONENT = /*@__PURE__*/new InjectionToken<ICarouselComponentBase>('IgxCarouselToken');
45+
1546
/** @hidden */
1647
export interface IgxSlideComponentBase {
1748
direction: Direction;

projects/igniteui-angular/src/lib/carousel/carousel.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { CarouselResourceStringsEN, ICarouselResourceStrings } from '../core/i18
3030
import { first, IBaseEventArgs, last, PlatformUtil } from '../core/utils';
3131
import { IgxAngularAnimationService } from '../services/animation/angular-animation-service';
3232
import { AnimationService } from '../services/animation/animation';
33-
import { Direction, IgxCarouselComponentBase } from './carousel-base';
33+
import { Direction, ICarouselComponentBase, IGX_CAROUSEL_COMPONENT, IgxCarouselComponentBase } from './carousel-base';
3434
import { IgxCarouselIndicatorDirective, IgxCarouselNextButtonDirective, IgxCarouselPrevButtonDirective } from './carousel.directives';
3535
import { IgxSlideComponent } from './slide.component';
3636
import { IgxIconComponent } from '../icon/icon.component';
@@ -75,7 +75,8 @@ export class CarouselHammerConfig extends HammerGestureConfig {
7575
{
7676
provide: HAMMER_GESTURE_CONFIG,
7777
useClass: CarouselHammerConfig
78-
}
78+
},
79+
{ provide: IGX_CAROUSEL_COMPONENT, useExisting: IgxCarouselComponent }
7980
],
8081
selector: 'igx-carousel',
8182
templateUrl: 'carousel.component.html',
@@ -88,7 +89,7 @@ export class CarouselHammerConfig extends HammerGestureConfig {
8889
imports: [IgxButtonDirective, IgxIconComponent, NgIf, NgClass, NgFor, NgTemplateOutlet]
8990
})
9091

91-
export class IgxCarouselComponent extends IgxCarouselComponentBase implements OnDestroy, AfterContentInit {
92+
export class IgxCarouselComponent extends IgxCarouselComponentBase implements ICarouselComponentBase, OnDestroy, AfterContentInit {
9293

9394
/**
9495
* Sets the `id` of the carousel.

projects/igniteui-angular/src/lib/carousel/slide.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Component, OnDestroy, Input, HostBinding, Output, EventEmitter, ElementRef, AfterContentChecked, booleanAttribute, Inject } from '@angular/core';
22
import { Subject } from 'rxjs';
3-
import { Direction, IgxSlideComponentBase } from './carousel-base';
4-
import { IgxCarouselComponent } from './carousel.component';
3+
import { Direction, ICarouselComponentBase, IGX_CAROUSEL_COMPONENT, IgxSlideComponentBase } from './carousel-base';
54

65
/**
76
* A slide component that usually holds an image and/or a caption text.
@@ -132,7 +131,7 @@ export class IgxSlideComponent implements AfterContentChecked, OnDestroy, IgxSli
132131

133132
constructor(
134133
private elementRef: ElementRef,
135-
@Inject(IgxCarouselComponent) private carousel: IgxCarouselComponent
134+
@Inject(IGX_CAROUSEL_COMPONENT) private carousel: ICarouselComponentBase
136135
) { }
137136

138137
/**

0 commit comments

Comments
 (0)