UNPKG

3.89 kBTypeScriptView Raw
1/***
2 * pause (not yet supported) (?string='hover') - event group name which pauses the cycling of the carousel, if hover pauses on mouseenter and resumes on mouseleave
3 keyboard (not yet supported) (?boolean=true) - if false carousel will not react to keyboard events
4 note: swiping not yet supported
5 */
6/****
7 * Problems:
8 * 1) if we set an active slide via model changes, .active class remains on a current slide.
9 * 2) if we have only one slide, we shouldn't show prev/next nav buttons
10 * 3) if first or last slide is active and noWrap is true, there should be "disabled" class on the nav buttons.
11 * 4) default interval should be equal 5000
12 */
13import { OnDestroy, EventEmitter } from '@angular/core';
14import { LinkedList } from '../utils';
15import { SlideComponent } from './slide.component';
16import { CarouselConfig } from './carousel.config';
17export declare enum Direction {
18 UNKNOWN = 0,
19 NEXT = 1,
20 PREV = 2,
21}
22/**
23 * Base element to create carousel
24 */
25export declare class CarouselComponent implements OnDestroy {
26 /** If `true` — carousel will not cycle continuously and will have hard stops (prevent looping) */
27 noWrap: boolean;
28 /** If `true` — will disable pausing on carousel mouse hover */
29 noPause: boolean;
30 protected _currentActiveSlide: number;
31 /** Will be emitted when active slide has been changed. Part of two-way-bindable [(activeSlide)] property */
32 activeSlideChange: EventEmitter<any>;
33 /** Index of currently displayed slide(started for 0) */
34 activeSlide: number;
35 protected _interval: number;
36 /**
37 * Delay of item cycling in milliseconds. If false, carousel won't cycle automatically.
38 */
39 interval: number;
40 protected _slides: LinkedList<SlideComponent>;
41 readonly slides: SlideComponent[];
42 protected currentInterval: any;
43 protected isPlaying: boolean;
44 protected destroyed: boolean;
45 readonly isBs4: boolean;
46 constructor(config: CarouselConfig);
47 ngOnDestroy(): void;
48 /**
49 * Adds new slide. If this slide is first in collection - set it as active and starts auto changing
50 * @param slide
51 */
52 addSlide(slide: SlideComponent): void;
53 /**
54 * Removes specified slide. If this slide is active - will roll to another slide
55 * @param slide
56 */
57 removeSlide(slide: SlideComponent): void;
58 /**
59 * Rolling to next slide
60 * @param force: {boolean} if true - will ignore noWrap flag
61 */
62 nextSlide(force?: boolean): void;
63 /**
64 * Rolling to previous slide
65 * @param force: {boolean} if true - will ignore noWrap flag
66 */
67 previousSlide(force?: boolean): void;
68 /**
69 * Rolling to specified slide
70 * @param index: {number} index of slide, which must be shown
71 */
72 selectSlide(index: number): void;
73 /**
74 * Starts a auto changing of slides
75 */
76 play(): void;
77 /**
78 * Stops a auto changing of slides
79 */
80 pause(): void;
81 /**
82 * Finds and returns index of currently displayed slide
83 * @returns {number}
84 */
85 getCurrentSlideIndex(): number;
86 /**
87 * Defines, whether the specified index is last in collection
88 * @param index
89 * @returns {boolean}
90 */
91 isLast(index: number): boolean;
92 /**
93 * Defines next slide index, depending of direction
94 * @param direction: Direction(UNKNOWN|PREV|NEXT)
95 * @param force: {boolean} if TRUE - will ignore noWrap flag, else will return undefined if next slide require wrapping
96 * @returns {any}
97 */
98 private findNextSlideIndex(direction, force);
99 /**
100 * Sets a slide, which specified through index, as active
101 * @param index
102 * @private
103 */
104 private _select(index);
105 /**
106 * Starts loop of auto changing of slides
107 */
108 private restartTimer();
109 /**
110 * Stops loop of auto changing of slides
111 */
112 private resetTimer();
113}