lazy.d.ts 2.2 KB

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