This is a (multiple allowed):
Create a swiper with lazy loading. Offset of the images is wrong, unless I resize the window when everything is loaded. ( The same appears when adding a video to a slide).
Correct Image offset, also with { centeredSlides: true }
offset is wrong
From example, it looks like this solves it for you, right?
lazyImageReady: function() {
console.log("lazy image ready");
this.updateSlides();
this.slideTo(this.activeIndex, 0, false);
}
unfortunately not. see a video here: https://nx5024.your-storageshare.de/s/YXW3p79HsHnJr4T. It only works correctly after resizing the browser window. Also does not work without data-srcset.
@niklasp
https://skr.sh/v50bBm7aAsu?a
Am I testing it wrong?
try:
on: {
lazyImageReady: (swiper) => {swiper.update()}
}
https://stackblitz.com/edit/lazy-loading-swiper-bug-cpdyap?file=index.html
@vltansky that last line of code fixed it for me. But i think the lazy loading feature needs more attention, as that somehow seems to me like a hack as it probably should be part of lazy loading, shouldn't it?
Yeah, I think so too.
@nolimits4web take a look on this. Is just adding swiper.update() just before emitting lazyImageReady a good solution?
Solution proposed by @vltansky is not a hack and should be used in this case (when images define slides sizes):
on: {
lazyImageReady: (swiper) => {swiper.update()}
}