autoplay.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import Swiper from '../swiper-class';
  2. export interface AutoplayMethods {
  3. /**
  4. * Whether autoplay enabled and running
  5. */
  6. running: boolean;
  7. /**
  8. * Start autoplay
  9. */
  10. start(): boolean;
  11. /**
  12. * Stop autoplay
  13. */
  14. stop(): boolean;
  15. }
  16. export interface AutoplayEvents {
  17. /**
  18. * Event will be fired in when autoplay started
  19. */
  20. autoplayStart: (swiper: Swiper) => void;
  21. /**
  22. * Event will be fired when autoplay stopped
  23. */
  24. autoplayStop: (swiper: Swiper) => void;
  25. /**
  26. * Event will be fired on autoplay pause (on mouse/pointer enter), when `pauseOnMouseEnter` enabled
  27. */
  28. autoplayPause: (swiper: Swiper) => void;
  29. /**
  30. * Event will be fired on autoplay resume (on mouse/pointer leave), when `pauseOnMouseEnter` enabled
  31. */
  32. autoplayResume: (swiper: Swiper) => void;
  33. /**
  34. * Event will be fired when slide changed with autoplay
  35. */
  36. autoplay: (swiper: Swiper) => void;
  37. }
  38. /**
  39. * Object with autoplay parameters or boolean `true` to enable with default settings.
  40. *
  41. * @example
  42. * ```js
  43. * const swiper = new Swiper('.swiper', {
  44. * autoplay: {
  45. * delay: 5000,
  46. * },
  47. * });
  48. * ```
  49. */
  50. export interface AutoplayOptions {
  51. /**
  52. * Delay between transitions (in ms). If this parameter is not specified, auto play will be disabled
  53. *
  54. * If you need to specify different delay for specific slides you can do it by using
  55. * `data-swiper-autoplay` (in ms) attribute on slide.
  56. *
  57. * @example
  58. * ```html
  59. * <!-- hold this slide for 2 seconds -->
  60. * <div class="swiper-slide" data-swiper-autoplay="2000">
  61. * ```
  62. *
  63. * @default 3000
  64. */
  65. delay?: number;
  66. /**
  67. * Enable this parameter and autoplay will be stopped when it reaches last slide (has no effect in loop mode)
  68. *
  69. * @default false
  70. */
  71. stopOnLastSlide?: boolean;
  72. /**
  73. * Set to `false` and autoplay will not be disabled after user interactions (swipes),
  74. * it will be restarted every time after interaction
  75. *
  76. * @default true
  77. */
  78. disableOnInteraction?: boolean;
  79. /**
  80. * Enables autoplay in reverse direction
  81. *
  82. * @default false
  83. */
  84. reverseDirection?: boolean;
  85. /**
  86. * When enabled autoplay will wait for wrapper transition to continue.
  87. * Can be disabled in case of using Virtual Translate when your
  88. * slider may not have transition
  89. *
  90. * @default true
  91. */
  92. waitForTransition?: boolean;
  93. /**
  94. * When enabled autoplay will be paused on mouse enter over Swiper container. If `disableOnInteraction` is also enabled, it will stop autoplay instead of pause
  95. *
  96. * @default false
  97. */
  98. pauseOnMouseEnter?: boolean;
  99. }