所以我似乎出于某种原因似乎会遇到此错误: [InfinitesCroll]支出器选项所需的图像
即使我已经声明了图像...这是我的代码:
$('.item-list').imagesLoaded(function () {
var $grid = $('.item-list');
$grid.isotope({
itemSelector: '.item-list__card',
percentPosition: true,
masonry: {
columnWidth: '.grid-sizer'
}
});
var iso = $grid.data('isotope');
$grid.infiniteScroll({
path: '.navigation a',
append: '.item-list__card',
debug: true,
status: '.infinite-scroll-request',
outlayer: iso
}
);
});
我在页面顶部加载插件和ES6:
import 'ImagesLoaded';
import Isotope from 'Isotope';
import InfiniteScroll from 'infinite-scroll';
不知道发生了什么事,希望有人可以提供帮助!
好的,好像我没有阅读WebPack安装的所有文档...我必须将无限滚动分配给已负载的Images。
InfiniteScroll.imagesLoaded = imagesLoaded;
所以我的完整代码是:
InfiniteScroll.imagesLoaded = imagesLoaded;
$('.item-list').imagesLoaded( function () {
var $grid = $('.item-list');
$grid.isotope({
itemSelector: '.item-list__card',
layoutMode: 'masonry',
masonry: {
columnWidth: '.grid-sizer',
horizontalOrder: true,
gutter: '.gutter-sizer',
},
percentPosition: true,
});
var iso = $grid.data('isotope');
$grid.infiniteScroll({
path: '.navigation a',
append: '.item-list__card',
debug: true,
status: '.infinite-scroll-request',
outlayer: iso,
//safari work around
onInit: function () {
this.on('load', function () {
$grid.isotope('layout');
})
}
}
);
// filter items on button click
$('.filter').on('click', 'button', function () {
var filterValue = $(this).attr('data-filter');
$grid.isotope({filter: filterValue});
});
});
无限卷轴在这里有一个很棒的教程,希望它有帮助!