carousel.component.d.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /***
  2. * pause (not yet supported) (?string='hover') - event group name which pauses
  3. * the cycling of the carousel, if hover pauses on mouseenter and resumes on
  4. * mouseleave keyboard (not yet supported) (?boolean=true) - if false
  5. * carousel will not react to keyboard events
  6. * note: swiping not yet supported
  7. */
  8. /****
  9. * Problems:
  10. * 1) if we set an active slide via model changes, .active class remains on a
  11. * current slide.
  12. * 2) if we have only one slide, we shouldn't show prev/next nav buttons
  13. * 3) if first or last slide is active and noWrap is true, there should be
  14. * "disabled" class on the nav buttons.
  15. * 4) default interval should be equal 5000
  16. */
  17. import { EventEmitter, NgZone, OnDestroy, AfterViewInit } from '@angular/core';
  18. import { LinkedList } from 'ngx-bootstrap/utils';
  19. import { SlideComponent } from './slide.component';
  20. import { CarouselConfig } from './carousel.config';
  21. import { SlideWithIndex } from './models';
  22. export declare enum Direction {
  23. UNKNOWN = 0,
  24. NEXT = 1,
  25. PREV = 2
  26. }
  27. /**
  28. * Base element to create carousel
  29. */
  30. export declare class CarouselComponent implements AfterViewInit, OnDestroy {
  31. private ngZone;
  32. noWrap: boolean;
  33. noPause: boolean;
  34. showIndicators: boolean;
  35. pauseOnFocus: boolean;
  36. indicatorsByChunk: boolean;
  37. itemsPerSlide: number;
  38. singleSlideOffset: boolean;
  39. /** Will be emitted when active slide has been changed. Part of two-way-bindable [(activeSlide)] property */
  40. activeSlideChange: EventEmitter<number>;
  41. /** Will be emitted when active slides has been changed in multilist mode */
  42. slideRangeChange: EventEmitter<number[]>;
  43. /** Index of currently displayed slide(started for 0) */
  44. activeSlide: number;
  45. startFromIndex: number;
  46. /**
  47. * Delay of item cycling in milliseconds. If false, carousel won't cycle
  48. * automatically.
  49. */
  50. interval: number;
  51. readonly slides: SlideComponent[];
  52. protected currentInterval: any;
  53. protected _currentActiveSlide: number;
  54. protected _interval: number;
  55. protected _slides: LinkedList<SlideComponent>;
  56. protected _chunkedSlides: SlideWithIndex[][];
  57. protected _slidesWithIndexes: SlideWithIndex[];
  58. protected _currentVisibleSlidesIndex: number;
  59. protected isPlaying: boolean;
  60. protected destroyed: boolean;
  61. readonly isBs4: boolean;
  62. constructor(config: CarouselConfig, ngZone: NgZone);
  63. ngAfterViewInit(): void;
  64. ngOnDestroy(): void;
  65. /**
  66. * Adds new slide. If this slide is first in collection - set it as active
  67. * and starts auto changing
  68. * @param slide
  69. */
  70. addSlide(slide: SlideComponent): void;
  71. /**
  72. * Removes specified slide. If this slide is active - will roll to another
  73. * slide
  74. * @param slide
  75. */
  76. removeSlide(slide: SlideComponent): void;
  77. nextSlideFromInterval(force?: boolean): void;
  78. /**
  79. * Rolling to next slide
  80. * @param force: {boolean} if true - will ignore noWrap flag
  81. */
  82. nextSlide(force?: boolean): void;
  83. /**
  84. * Rolling to previous slide
  85. * @param force: {boolean} if true - will ignore noWrap flag
  86. */
  87. previousSlide(force?: boolean): void;
  88. getFirstVisibleIndex(): number;
  89. getLastVisibleIndex(): number;
  90. getActive: (slide: SlideComponent) => boolean;
  91. move(direction: Direction, force?: boolean): void;
  92. /**
  93. * Swith slides by enter, space and arrows keys
  94. * @internal
  95. */
  96. keydownPress(event: KeyboardEvent): void;
  97. /**
  98. * Play on mouse leave
  99. * @internal
  100. */
  101. onMouseLeave(): void;
  102. /**
  103. * Play on mouse up
  104. * @internal
  105. */
  106. onMouseUp(): void;
  107. /**
  108. * When slides on focus autoplay is stopped(optional)
  109. * @internal
  110. */
  111. pauseFocusIn(): void;
  112. /**
  113. * When slides out of focus autoplay is started
  114. * @internal
  115. */
  116. pauseFocusOut(): void;
  117. /**
  118. * Rolling to specified slide
  119. * @param index: {number} index of slide, which must be shown
  120. */
  121. selectSlide(index: number): void;
  122. /**
  123. * Starts a auto changing of slides
  124. */
  125. play(): void;
  126. /**
  127. * Stops a auto changing of slides
  128. */
  129. pause(): void;
  130. /**
  131. * Finds and returns index of currently displayed slide
  132. */
  133. getCurrentSlideIndex(): number;
  134. /**
  135. * Defines, whether the specified index is last in collection
  136. * @param index
  137. */
  138. isLast(index: number): boolean;
  139. /**
  140. * Defines, whether the specified index is first in collection
  141. * @param index
  142. */
  143. isFirst(index: number): boolean;
  144. indicatorsSlides(): SlideComponent[];
  145. private selectInitialSlides;
  146. /**
  147. * Defines next slide index, depending of direction
  148. * @param direction: Direction(UNKNOWN|PREV|NEXT)
  149. * @param force: {boolean} if TRUE - will ignore noWrap flag, else will
  150. * return undefined if next slide require wrapping
  151. */
  152. private findNextSlideIndex;
  153. private mapSlidesAndIndexes;
  154. private selectSlideRange;
  155. private selectRangeByNestedIndex;
  156. private isIndexOnTheEdges;
  157. private isIndexInRange;
  158. private hideSlides;
  159. private isVisibleSlideListLast;
  160. private isVisibleSlideListFirst;
  161. private moveSliderByOneItem;
  162. private makeSlidesConsistent;
  163. private moveMultilist;
  164. private getVisibleIndexes;
  165. /**
  166. * Sets a slide, which specified through index, as active
  167. * @param index
  168. */
  169. private _select;
  170. /**
  171. * Starts loop of auto changing of slides
  172. */
  173. private restartTimer;
  174. readonly multilist: boolean;
  175. /**
  176. * Stops loop of auto changing of slides
  177. */
  178. private resetTimer;
  179. }