@@ -4,10 +4,10 @@ import {
4
4
DestroyRef ,
5
5
effect ,
6
6
ElementRef ,
7
- Inject ,
8
7
inject ,
9
8
input ,
10
9
linkedSignal ,
10
+ numberAttribute ,
11
11
OnDestroy ,
12
12
OnInit ,
13
13
output
@@ -37,28 +37,30 @@ import { CarouselConfig } from '../carousel.config';
37
37
}
38
38
} )
39
39
export class CarouselComponent implements OnInit , OnDestroy , AfterContentInit {
40
+ private config = inject < CarouselConfig > ( CarouselConfig ) ;
41
+
40
42
readonly #hostElement = inject ( ElementRef ) ;
41
43
readonly #carouselService = inject ( CarouselService ) ;
42
44
readonly #carouselState = inject ( CarouselState ) ;
43
45
readonly #intersectionService = inject ( IntersectionService ) ;
44
46
readonly #listenersService = inject ( ListenersService ) ;
45
47
46
- constructor ( @ Inject ( CarouselConfig ) private config : CarouselConfig ) {
48
+ constructor ( ) {
47
49
this . loadConfig ( ) ;
48
50
}
49
51
50
52
loadConfig ( ) {
51
- this . activeIndex . set ( this . config ?. activeIndex ?? this . activeIndex ( ) ) ;
52
- this . animate . set ( this . config ?. animate ?? this . animate ( ) ) ;
53
- this . direction . set ( this . config ?. direction ?? this . direction ( ) ) ;
54
- this . interval . set ( this . config ?. interval ?? this . interval ( ) ) ;
53
+ this . activeIndex . update ( ( activeIndex ) => this . config ?. activeIndex ?? activeIndex ) ;
54
+ this . animate . update ( ( animate ) => this . config ?. animate ?? animate ) ;
55
+ this . direction . update ( ( direction ) => this . config ?. direction ?? direction ) ;
56
+ this . interval . update ( ( interval ) => this . config ?. interval ?? interval ) ;
55
57
}
56
58
57
59
/**
58
60
* Index of the active item.
59
61
* @return number
60
62
*/
61
- readonly activeIndexInput = input < number > ( 0 , { alias : 'activeIndex' } ) ;
63
+ readonly activeIndexInput = input ( 0 , { alias : 'activeIndex' , transform : numberAttribute } ) ;
62
64
63
65
readonly activeIndex = linkedSignal ( {
64
66
source : this . activeIndexInput ,
@@ -92,7 +94,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
92
94
* @return number
93
95
* @default 0
94
96
*/
95
- readonly intervalInput = input < number > ( 0 , { alias : 'interval' } ) ;
97
+ readonly intervalInput = input ( - 1 , { alias : 'interval' , transform : numberAttribute } ) ;
96
98
97
99
readonly interval = linkedSignal ( {
98
100
source : this . intervalInput ,
0 commit comments