こちらのコミュニティからの以前の投稿のおかげで、かなりうまく機能するピクチャーフィルと一緒に遅延読み込みを使用する Flexslider ギャラリーがここにあります。
唯一の問題は、ギャラリーの最後のサムネイルをクリックすると、スライダーがそのスライドにスライドしますが、まだ何もロードされていないことです。ここでロジックを手伝ってくれる人はいますか?
クリックされた親指に読み込まれた画像があることを確認してからスライドする前に、そうでない場合は画像を読み込んでください。
http://codepen.io/anon/pen/OVveXK
var mainSlide = $('#slider-main');
var navSlide = $('#slider-nav');
mainSlide.flexslider({
animation: 'slide',
controlNav: false,
animationLoop: false,
slideshow: false,
start: function (slider) {
navSlide.addClass('flex-attached');
/* lazy load first image with picturefill */
$(slider).find('.slides').children().eq(1).find('div.img span.lazy').each(function (i, elm) {
var $elm = $(elm);
var src = $elm.find('img').attr('data-src');
$elm.find('img').attr('src', src);
var content = $elm.html();
var $pic = $('<picture id="' + $elm.attr('id') + '">' + content + '</picture>');
var pic = $pic[0];
$elm.after(pic); // insert the picture
$elm.remove(); // remove the span
window.picturefill({ elements: [pic] });
});
},
after: function (slider) {
/* lazy load next image with picturefill */
$(slider).find('.slides').children().eq(slider.animatingTo + 1).find('div.img span.lazy').each(function (i, elm) {
var $elm = $(elm);
var src = $elm.find('img').attr('data-src');
$elm.find('img').attr('src', src);
var content = $elm.html();
var $pic = $('<picture id="' + $elm.attr('id') + '">' + content + '</picture>');
var pic = $pic[0];
$elm.after(pic); // insert the picture
$elm.remove(); // remove the span
window.picturefill({ elements: [pic] });
});
}
});
navSlide.flexslider({
animation: 'slide',
controlNav: false,
animationLoop: false,
slideshow: false,
asNavFor: '#slider-main',
itemWidth: 120,
itemMargin: 5,
directionNav: false,
start: function () {
navSlide.addClass('flex-attached');
}
});