Browse Source

Add support for `data-lazy-srcset`

pull/243/head
Jānis Skarnelis 3 years ago
parent
commit
8dd107028b
  1. 11
      src/Carousel/Carousel.js

11
src/Carousel/Carousel.js

@ -610,9 +610,8 @@ export class Carousel extends Base {
slide.$el.dataset.index = slide.index;
// Lazy load images
const $lazyNodes = slide.$el.querySelectorAll("[data-lazy-src]");
$lazyNodes.forEach((node) => {
// ===
slide.$el.querySelectorAll("[data-lazy-src]").forEach((node) => {
let lazySrc = node.dataset.lazySrc;
if (node instanceof HTMLImageElement) {
@ -622,6 +621,12 @@ export class Carousel extends Base {
}
});
slide.$el.querySelectorAll("[data-lazy-srcset]").forEach((node) => {
node.srcset = node.dataset.lazySrcset;
});
// Lazy load slide background image
// ===
let lazySrc;
if ((lazySrc = slide.$el.dataset.lazySrc)) {

Loading…
Cancel
Save