我正在使用 OwlCarousel 2.0.0-beta.2.4 来显示特定内容类型的所有文章的图像、标题和 dek。这些内容类型可以有数百篇文章。因此,一旦用户到达轮播中的最后一张幻灯片,我将显示前六个,然后延迟加载接下来的六个。
根据Owl Docs,这可以通过触发“add.owl.carousel”事件并指定要添加的项目以及位置来实现。如果将项目添加到位置 0-5,这可以正常工作,但对于位置 6-11 等根本不起作用。我尝试了几种不同的方法,包括addItem()。根据非常有限的文档,这是它应该工作的方式(我认为):
BucketCarousel.prototype.fetchMoreItems = function(callback) {
var self = this;
$.ajax(this.fetchURL, {
dataType: 'json',
data: {page: this.page},
error: function(response) {
console.log('error', response);
},
success: function(response) {
$(response.bucket_items).each(function(index, item) {
var pos = self.position+index;
self.owlCarousel.trigger('add.owl.carousel', [item, pos]);
});
self.hasmore = response.has_more;
self.page++;
(callback || $.noop).apply(self);
}
});
};
如果我设置var pos = index; ,内容按预期添加到轮播的开头。关于如何让猫头鹰将项目附加到轮播末尾的任何想法?