@@ -19,19 +19,34 @@ import { filter, finalize, withLatestFrom, zipWith } from 'rxjs/operators';
1919import { IntersectionService } from '../../services' ;
2020import { IListenersConfig , ListenersService } from '../../services' ;
2121
22+ import { Triggers } from '../../coreui.types' ;
23+ import { ThemeDirective } from '../../shared/theme.directive' ;
2224import { CarouselState } from '../carousel-state' ;
2325import { CarouselService } from '../carousel.service' ;
2426import { CarouselConfig } from '../carousel.config' ;
25- import { Triggers } from '../../coreui.types' ;
2627
2728@Component ( {
2829 selector : 'c-carousel' ,
29- template : '<ng-content></ng-content >' ,
30+ template : '<ng-content / >' ,
3031 styleUrls : [ './carousel.component.scss' ] ,
3132 providers : [ CarouselService , CarouselState , CarouselConfig , ListenersService ] ,
32- standalone : true
33+ standalone : true ,
34+ hostDirectives : [
35+ { directive : ThemeDirective , inputs : [ 'dark' ] }
36+ ]
3337} )
3438export class CarouselComponent implements OnInit , OnDestroy , AfterContentInit {
39+ constructor (
40+ @Inject ( CarouselConfig ) private config : CarouselConfig ,
41+ private hostElement : ElementRef ,
42+ private carouselService : CarouselService ,
43+ private carouselState : CarouselState ,
44+ private intersectionService : IntersectionService ,
45+ private listenersService : ListenersService
46+ ) {
47+ Object . assign ( this , config ) ;
48+ }
49+
3550 /**
3651 * Index of the active item.
3752 * @type number
@@ -42,11 +57,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
4257 * @type boolean
4358 */
4459 @Input ( ) animate : boolean = true ;
45- /**
46- * Add darker controls, indicators, and captions.
47- * @type boolean
48- */
49- @Input ( ) dark ?: boolean ;
5060 /**
5161 * Carousel direction. [docs]
5262 * @type {'next' | 'prev' }
@@ -92,7 +102,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
92102 return {
93103 carousel : true ,
94104 slide : true ,
95- 'carousel-dark' : ! ! this . dark ,
96105 'carousel-fade' : this . transition === 'crossfade'
97106 } ;
98107 }
@@ -102,17 +111,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
102111 private swipeSubscription ?: Subscription ;
103112 readonly #destroyRef = inject ( DestroyRef ) ;
104113
105- constructor (
106- @Inject ( CarouselConfig ) private config : CarouselConfig ,
107- private hostElement : ElementRef ,
108- private carouselService : CarouselService ,
109- private carouselState : CarouselState ,
110- private intersectionService : IntersectionService ,
111- private listenersService : ListenersService
112- ) {
113- Object . assign ( this , config ) ;
114- }
115-
116114 ngOnInit ( ) : void {
117115 this . carouselStateSubscribe ( ) ;
118116 }
@@ -190,6 +188,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
190188 }
191189
192190 private intersectionServiceSubscribe ( ) : void {
191+ this . intersectionService . createIntersectionObserver ( this . hostElement ) ;
193192 this . intersectionService . intersecting$
194193 . pipe (
195194 filter ( next => next . hostElement === this . hostElement ) ,
@@ -202,7 +201,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
202201 this . visible = next . isIntersecting ;
203202 next . isIntersecting ? this . setTimer ( ) : this . resetTimer ( ) ;
204203 } ) ;
205- this . intersectionService . createIntersectionObserver ( this . hostElement ) ;
206204 }
207205
208206 private swipeSubscribe ( subscribe : boolean = true ) : void {
0 commit comments