UNPKG

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