I am lazyloading the images on this site with jquery lazyload and a treshold: https://bm-translations.de/#leistungen
//Lazyload Images with Threshold https://www.appelsiini.net/projects/lazyload
$(function() {
$("img.lazy").lazyload({
threshold : 400
});
});
So Images src
is replaced by data-original
. When I scroll to the element it should change it to src
, as it.
But out of some reason its loading the images in the bootstrap-slider too slow (when I click to it or its autosliding some images havent loaded), as you can see. How to adjust this code, so its working for this as well?
The slider has a general structure like that: https://www.w3schools.com/bootstrap/bootstrap_carousel.asp
Carousel JS is:
$('#myCarousel').carousel({
interval: 9000,
});
// handles the carousel buttons
$('[id^=carousel-selector-]').click( function(){
var id_selector = $(this).attr("id");
var id = id_selector.substr(id_selector.length -1);
id = parseInt(id);
$('#myCarousel').carousel(id);
$('[id^=carousel-selector-]').removeClass('selected');
$(this).addClass('selected');
});
// when the carousel slides, auto update
$('#myCarousel').on('slide.bs.carousel', function (e) {
var id = $('.item.active').data('slide-number');
id = parseInt(id)+1;
$('[id^=carousel-selector-]').removeClass('selected');
$('[id=carousel-selector-'+id+']').addClass('selected');
});
I tried this, but then it wasnt sliding anymore:
$('#myCarousel').carousel({
interval: 9000,
scroll: {
onBefore: function( data ) {
var $current = data.items.visible.first(),
visible = data.items.visible,
src = visible.data('src');
visible.attr('src', src);
}
}
});
How to fix it, so its either lazy-loading before click/autoslide or at least to lazyload the whole carousel images with threshold?