Skip to content

Commit 86a6aaf

Browse files
committed
refactor(carousel): add interval to carousel state
1 parent 84e30a1 commit 86a6aaf

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

projects/coreui-angular/src/lib/carousel/carousel-state.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export class CarouselState {
1212
animate: true,
1313
items: [],
1414
direction: 'next',
15-
transition: 'slide'
15+
transition: 'slide',
16+
interval: 0
1617
};
1718

1819
get state(): ICarouselState {
@@ -75,7 +76,8 @@ export class CarouselState {
7576
animate: true,
7677
items: [],
7778
direction: 'next',
78-
transition: 'slide'
79+
transition: 'slide',
80+
interval: 0
7981
};
8082
}
8183
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { CarouselItemComponent } from './carousel-item/carousel-item.component';
22

33
export interface ICarouselOptions {
4-
interval?: number;
5-
animate?: boolean;
64
activeIndex?: number;
5+
animate?: boolean;
76
direction?: 'next' | 'prev';
7+
interval?: number;
88
transition?: 'slide' | 'crossfade';
99
}
1010

1111
export interface ICarouselState {
1212
activeItemIndex?: number;
1313
animate?: boolean;
14-
items?: CarouselItemComponent[];
1514
direction?: 'next' | 'prev';
15+
interval?: number;
16+
items?: CarouselItemComponent[];
1617
transition?: 'slide' | 'crossfade';
1718
}

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
100100
});
101101

102102
readonly #intervalEffect = effect(() => {
103-
this.interval() ? this.setTimer() : this.resetTimer();
103+
const interval = this.interval();
104+
this.#carouselState.state = { interval: interval };
105+
interval ? this.setTimer() : this.resetTimer();
104106
});
105107

106108
/**
@@ -156,6 +158,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
156158
this.#carouselState.state = {
157159
activeItemIndex: this.activeIndex(),
158160
animate: this.animate(),
161+
interval: this.interval(),
159162
transition: this.transition()
160163
};
161164
this.setListeners();

0 commit comments

Comments
 (0)