carousel.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /** Returns a new `BaseComponent` instance. */
  2. declare class BaseComponent {
  3. element: Element;
  4. options?: BaseOptions;
  5. /**
  6. * @param target `Element` or selector string
  7. * @param config component instance options
  8. */
  9. constructor(target: Element | string, config?: BaseOptions);
  10. get version(): string;
  11. get name(): string;
  12. get defaults(): {};
  13. /** just to have something to extend from */
  14. _toggleEventListeners: () => void;
  15. /** Removes component from target element. */
  16. dispose(): void;
  17. }
  18. declare interface BaseOptions {
  19. [key: string]: unknown;
  20. }
  21. /** Creates a new `Carousel` instance. */
  22. declare class Carousel extends BaseComponent {
  23. static selector: string;
  24. static init: (element: Element) => Carousel;
  25. static getInstance: (element: Element) => Carousel | null;
  26. element: HTMLElement;
  27. options: CarouselOptions;
  28. direction: "right" | "left";
  29. index: number;
  30. isTouch: boolean;
  31. slides: HTMLCollectionOf<HTMLElement>;
  32. controls: HTMLElement[];
  33. indicator: HTMLElement | null;
  34. indicators: HTMLElement[];
  35. /**
  36. * @param target mostly a `.carousel` element
  37. * @param config instance options
  38. */
  39. constructor(target: Element | string, config?: Partial<CarouselOptions>);
  40. /**
  41. * Returns component name string.
  42. */
  43. get name(): string;
  44. /**
  45. * Returns component default options.
  46. */
  47. get defaults(): CarouselOptions;
  48. /**
  49. * Check if instance is paused.
  50. */
  51. get isPaused(): boolean;
  52. /**
  53. * Check if instance is animating.
  54. */
  55. get isAnimating(): boolean;
  56. /** Slide automatically through items. */
  57. cycle(): void;
  58. /** Pause the automatic cycle. */
  59. pause(): void;
  60. /** Slide to the next item. */
  61. next(): void;
  62. /** Slide to the previous item. */
  63. prev(): void;
  64. /**
  65. * Jump to the item with the `idx` index.
  66. *
  67. * @param idx the index of the item to jump to
  68. */
  69. to(idx: number): void;
  70. /**
  71. * Toggles all event listeners for the `Carousel` instance.
  72. *
  73. * @param add when `TRUE` event listeners are added
  74. */
  75. _toggleEventListeners: (add?: boolean) => void;
  76. /** Remove `Carousel` component from target. */
  77. dispose(): void;
  78. }
  79. export default Carousel;
  80. declare interface CarouselOptions extends BaseOptions {
  81. pause: boolean | "hover";
  82. keyboard: boolean;
  83. touch: boolean;
  84. interval: number | boolean;
  85. }
  86. export { }