pagination.d.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import { Dom7Array } from 'dom7';
  2. import { CSSSelector } from '../shared';
  3. import Swiper from '../swiper-class';
  4. export interface PaginationMethods {
  5. /**
  6. * HTMLElement of pagination container element
  7. */
  8. el: HTMLElement;
  9. /**
  10. * Dom7 array-like collection of pagination bullets
  11. * HTML elements. To get specific slide HTMLElement
  12. * use `swiper.pagination.bullets[1]`.
  13. */
  14. bullets: Dom7Array;
  15. /**
  16. * Render pagination layout
  17. */
  18. render(): void;
  19. /**
  20. * Update pagination state (enabled/disabled/active)
  21. */
  22. update(): void;
  23. /**
  24. * Initialize pagination
  25. */
  26. init(): void;
  27. /**
  28. * Destroy pagination
  29. */
  30. destroy(): void;
  31. }
  32. export interface PaginationEvents {
  33. /**
  34. * Event will be fired after pagination rendered
  35. */
  36. paginationRender: (swiper: Swiper, paginationEl: HTMLElement) => void;
  37. /**
  38. * Event will be fired when pagination updated
  39. */
  40. paginationUpdate: (swiper: Swiper, paginationEl: HTMLElement) => void;
  41. /**
  42. * Event will be fired on pagination hide
  43. */
  44. paginationHide: (swiper: Swiper) => void;
  45. /**
  46. * Event will be fired on pagination show
  47. */
  48. paginationShow: (swiper: Swiper) => void;
  49. }
  50. export interface PaginationOptions {
  51. /**
  52. * String with CSS selector or HTML element of the container with pagination
  53. *
  54. * @default null
  55. */
  56. el?: CSSSelector | HTMLElement | null;
  57. /**
  58. * String with type of pagination. Can be `'bullets'`, `'fraction'`, `'progressbar'` or `'custom'`
  59. *
  60. * @default 'bullets'
  61. */
  62. type?: 'bullets' | 'fraction' | 'progressbar' | 'custom';
  63. /**
  64. * Defines which HTML tag will be used to represent single pagination bullet. Only for `'bullets'` pagination type.
  65. *
  66. * @default 'span'
  67. */
  68. bulletElement?: string;
  69. /**
  70. * Good to enable if you use bullets pagination with a lot of slides. So it will keep only few bullets visible at the same time.
  71. *
  72. * @default false
  73. */
  74. dynamicBullets?: boolean;
  75. /**
  76. * The number of main bullets visible when `dynamicBullets` enabled.
  77. *
  78. * @default 1
  79. */
  80. dynamicMainBullets?: number;
  81. /**
  82. * Toggle (hide/show) pagination container visibility after click on Slider's container
  83. *
  84. * @default true
  85. */
  86. hideOnClick?: boolean;
  87. /**
  88. * If `true` then clicking on pagination button will cause transition to appropriate slide. Only for bullets pagination type
  89. *
  90. * @default false
  91. */
  92. clickable?: boolean;
  93. /**
  94. * Makes pagination progressbar opposite to Swiper's `direction` parameter, means vertical progressbar for horizontal swiper
  95. * direction and horizontal progressbar for vertical swiper direction
  96. *
  97. * @default false
  98. */
  99. progressbarOpposite?: boolean;
  100. /**
  101. * format fraction pagination current number. Function receives current number,
  102. * and you need to return formatted value
  103. */
  104. formatFractionCurrent?: (number: number) => number;
  105. /**
  106. * format fraction pagination total number. Function receives total number, and you
  107. * need to return formatted value
  108. */
  109. formatFractionTotal?: (number: number) => number;
  110. /**
  111. * This parameter allows totally customize pagination bullets, you need to pass here a function that accepts `index` number of
  112. * pagination bullet and required element class name (`className`). Only for `'bullets'` pagination type
  113. *
  114. * @default null
  115. *
  116. * @example
  117. * ```js
  118. * const swiper = new Swiper('.swiper', {
  119. * //...
  120. * renderBullet: function (index, className) {
  121. * return '<span class="' + className + '">' + (index + 1) + '</span>';
  122. * }
  123. * });
  124. * ```
  125. */
  126. renderBullet?: (index: number, className: string) => void;
  127. /**
  128. * This parameter allows to customize "fraction" pagination html. Only for `'fraction'` pagination type
  129. *
  130. * @default null
  131. *
  132. * @example
  133. * ```js
  134. * const swiper = new Swiper('.swiper', {
  135. * //...
  136. * renderFraction: function (currentClass, totalClass) {
  137. * return '<span class="' + currentClass + '"></span>' +
  138. * ' of ' +
  139. * '<span class="' + totalClass + '"></span>';
  140. * }
  141. * });
  142. * ```
  143. */
  144. renderFraction?: (currentClass: string, totalClass: string) => void;
  145. /**
  146. * This parameter allows to customize "progress" pagination. Only for `'progress'` pagination type
  147. *
  148. * @default null
  149. *
  150. * @example
  151. * ```js
  152. * const swiper = new Swiper('.swiper', {
  153. * //...
  154. * renderProgressbar: function (progressbarFillClass) {
  155. * return '<span class="' + progressbarFillClass + '"></span>';
  156. * }
  157. * });
  158. * ```
  159. */
  160. renderProgressbar?: (progressbarFillClass: string) => void;
  161. /**
  162. * This parameter is required for `'custom'` pagination type where you have to specify
  163. * how it should be rendered.
  164. *
  165. * @default null
  166. *
  167. * @example
  168. * ```js
  169. * const swiper = new Swiper('.swiper', {
  170. * //...
  171. * renderCustom: function (swiper, current, total) {
  172. * return current + ' of ' + total;
  173. * }
  174. * });
  175. * ```
  176. */
  177. renderCustom?: (swiper: Swiper, current: number, total: number) => void;
  178. /**
  179. * CSS class name of single pagination bullet
  180. *
  181. * @default 'swiper-pagination-bullet'
  182. */
  183. bulletClass?: string;
  184. /**
  185. * CSS class name of currently active pagination bullet
  186. *
  187. * @default 'swiper-pagination-bullet-active'
  188. */
  189. bulletActiveClass?: string;
  190. /**
  191. * The beginning of the modifier CSS class name that will be added to pagination depending on parameters
  192. *
  193. * @default 'swiper-pagination-'
  194. */
  195. modifierClass?: string;
  196. /**
  197. * CSS class name of the element with currently active index in "fraction" pagination
  198. *
  199. * @default 'swiper-pagination-current'
  200. */
  201. currentClass?: string;
  202. /**
  203. * CSS class name of the element with total number of "snaps" in "fraction" pagination
  204. *
  205. * @default 'swiper-pagination-total'
  206. */
  207. totalClass?: string;
  208. /**
  209. * CSS class name of pagination when it becomes inactive
  210. *
  211. * @default 'swiper-pagination-hidden'
  212. */
  213. hiddenClass?: string;
  214. /**
  215. * CSS class name of pagination progressbar fill element
  216. *
  217. * @default 'swiper-pagination-progressbar-fill'
  218. */
  219. progressbarFillClass?: string;
  220. /**
  221. * CSS class name of pagination progressbar opposite
  222. *
  223. * @default 'swiper-pagination-progressbar-opposite'
  224. */
  225. progressbarOppositeClass?: string;
  226. /**
  227. * CSS class name set to pagination when it is clickable
  228. *
  229. * @default 'swiper-pagination-clickable'
  230. */
  231. clickableClass?: string;
  232. /**
  233. * CSS class name set to pagination when it is disabled
  234. *
  235. * @default 'swiper-pagination-lock'
  236. */
  237. lockClass?: string;
  238. /**
  239. * CSS class name set to pagination in horizontal Swiper
  240. *
  241. * @default 'swiper-pagination-horizontal'
  242. */
  243. horizontalClass?: string;
  244. /**
  245. * CSS class name set to pagination in vertical Swiper
  246. *
  247. * @default 'swiper-pagination-vertical'
  248. */
  249. verticalClass?: string;
  250. }