UNPKG

2.27 kBTypeScriptView Raw
1import { Dom7Array } from 'dom7';
2import { CSSSelector } from '../shared';
3import Swiper from '../swiper-class';
4
5export interface LazyMethods {
6 /**
7 * Load/update lazy images based on current slider state (position)
8 */
9 load(): void;
10
11 /**
12 * Force to load lazy images in slide by specified index
13 * @param number index number of slide to load lazy images in
14 */
15 loadInSlide(index: number): void;
16}
17
18export interface LazyEvents {
19 /**
20 * Event will be fired in the beginning of lazy loading of image
21 */
22 lazyImageLoad: (swiper: Swiper, slideEl: HTMLElement, imageEl: HTMLElement) => void;
23 /**
24 * Event will be fired when lazy loading image will be loaded
25 */
26 lazyImageReady: (swiper: Swiper, slideEl: HTMLElement, imageEl: HTMLElement) => void;
27}
28
29export interface LazyOptions {
30 /**
31 * Whether the lazy loading images is enabled
32 */
33 enabled?: boolean;
34 /**
35 * Enables to check is the Swiper in view before lazy loading images on initial slides
36 *
37 * @default false
38 */
39 checkInView?: boolean;
40 /**
41 * Element to check scrolling on for `checkInView`. Defaults to `window`
42 * */
43 scrollingElement?: CSSSelector | null | Dom7Array | HTMLElement;
44 /**
45 * Set to `true` to enable lazy loading for the closest slides images (for previous and next slide images)
46 *
47 * @default false
48 * */
49 loadPrevNext?: boolean;
50 /**
51 * Amount of next/prev slides to preload lazy images in. Can't be less than `slidesPerView`
52 *
53 * @default 1
54 * */
55 loadPrevNextAmount?: number;
56 /**
57 * By default, Swiper will load lazy images after transition to this slide, so you may enable this parameter if you need it to start loading of new image in the beginning of transition
58 *
59 * @default false
60 * */
61 loadOnTransitionStart?: boolean;
62 /**
63 * CSS class name of lazy element
64 *
65 * @default 'swiper-lazy'
66 * */
67 elementClass?: string;
68 /**
69 * CSS class name of lazy loading element
70 *
71 * @default 'swiper-lazy-loading'
72 * */
73 loadingClass?: string;
74 /**
75 * CSS class name of lazy loaded element
76 *
77 * @default 'swiper-lazy-loaded'
78 * */
79 loadedClass?: string;
80 /**
81 * CSS class name of lazy preloader
82 *
83 * @default 'swiper-lazy-preloader'
84 * */
85 preloaderClass?: string;
86}