@@ -19,19 +19,34 @@ import { filter, finalize, withLatestFrom, zipWith } from 'rxjs/operators';
19
19
import { IntersectionService } from '../../services' ;
20
20
import { IListenersConfig , ListenersService } from '../../services' ;
21
21
22
+ import { Triggers } from '../../coreui.types' ;
23
+ import { ThemeDirective } from '../../shared/theme.directive' ;
22
24
import { CarouselState } from '../carousel-state' ;
23
25
import { CarouselService } from '../carousel.service' ;
24
26
import { CarouselConfig } from '../carousel.config' ;
25
- import { Triggers } from '../../coreui.types' ;
26
27
27
28
@Component ( {
28
29
selector : 'c-carousel' ,
29
- template : '<ng-content></ng-content >' ,
30
+ template : '<ng-content / >' ,
30
31
styleUrls : [ './carousel.component.scss' ] ,
31
32
providers : [ CarouselService , CarouselState , CarouselConfig , ListenersService ] ,
32
- standalone : true
33
+ standalone : true ,
34
+ hostDirectives : [
35
+ { directive : ThemeDirective , inputs : [ 'dark' ] }
36
+ ]
33
37
} )
34
38
export 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
+
35
50
/**
36
51
* Index of the active item.
37
52
* @type number
@@ -42,11 +57,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
42
57
* @type boolean
43
58
*/
44
59
@Input ( ) animate : boolean = true ;
45
- /**
46
- * Add darker controls, indicators, and captions.
47
- * @type boolean
48
- */
49
- @Input ( ) dark ?: boolean ;
50
60
/**
51
61
* Carousel direction. [docs]
52
62
* @type {'next' | 'prev' }
@@ -92,7 +102,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
92
102
return {
93
103
carousel : true ,
94
104
slide : true ,
95
- 'carousel-dark' : ! ! this . dark ,
96
105
'carousel-fade' : this . transition === 'crossfade'
97
106
} ;
98
107
}
@@ -102,17 +111,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
102
111
private swipeSubscription ?: Subscription ;
103
112
readonly #destroyRef = inject ( DestroyRef ) ;
104
113
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
-
116
114
ngOnInit ( ) : void {
117
115
this . carouselStateSubscribe ( ) ;
118
116
}
@@ -190,6 +188,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
190
188
}
191
189
192
190
private intersectionServiceSubscribe ( ) : void {
191
+ this . intersectionService . createIntersectionObserver ( this . hostElement ) ;
193
192
this . intersectionService . intersecting$
194
193
. pipe (
195
194
filter ( next => next . hostElement === this . hostElement ) ,
@@ -202,7 +201,6 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
202
201
this . visible = next . isIntersecting ;
203
202
next . isIntersecting ? this . setTimer ( ) : this . resetTimer ( ) ;
204
203
} ) ;
205
- this . intersectionService . createIntersectionObserver ( this . hostElement ) ;
206
204
}
207
205
208
206
private swipeSubscribe ( subscribe : boolean = true ) : void {
0 commit comments