UNPKG

2.28 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 * @default false
34 */
35 enabled?: boolean;
36 /**
37 * Enables to check is the Swiper in view before lazy loading images on initial slides
38 *
39 * @default false
40 */
41 checkInView?: boolean;
42 /**
43 * Element to check scrolling on for `checkInView`. Defaults to `window`
44 */
45 scrollingElement?: CSSSelector | null | Dom7Array | HTMLElement;
46 /**
47 * Set to `true` to enable lazy loading for the closest slides images (for previous and next slide images)
48 *
49 * @default false
50 */
51 loadPrevNext?: boolean;
52 /**
53 * Amount of next/prev slides to preload lazy images in. Can't be less than `slidesPerView`
54 *
55 * @default 1
56 */
57 loadPrevNextAmount?: number;
58 /**
59 * 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
60 *
61 * @default false
62 */
63 loadOnTransitionStart?: boolean;
64 /**
65 * CSS class name of lazy element
66 *
67 * @default 'swiper-lazy'
68 */
69 elementClass?: string;
70 /**
71 * CSS class name of lazy loading element
72 *
73 * @default 'swiper-lazy-loading'
74 */
75 loadingClass?: string;
76 /**
77 * CSS class name of lazy loaded element
78 *
79 * @default 'swiper-lazy-loaded'
80 */
81 loadedClass?: string;
82 /**
83 * CSS class name of lazy preloader
84 *
85 * @default 'swiper-lazy-preloader'
86 */
87 preloaderClass?: string;
88}