使用 infinite-scroll.js 库在内容加载后执行回调
Do a callback after content load with infinite-scroll.js library
是否可以在使用 infinite-scroll.js 库加载后调用函数?
我看到一个调用 init 的函数:
onInit: function() {
this.on( 'load', function() {
var ancho = parseFloat($('.imagen').innerWidth());
$('.normal img').css("width", ancho);
$('.hover img').css("width", ancho);
});
}
https://infinite-scroll.com/options.html#oninit
是否可以在加载内容后调用函数?
编辑
这是下面答案后的更新代码。
var inf = $('.col-trabajos').infiniteScroll({
path: '.nav-previous a',
append: '.article',
history: false,
hideNav: '.nav-links',
});
// callback
inf.on( 'append.infiniteScroll', function( event, response, path, items ) {
var ancho = $('.imagen').innerWidth();
$('.normal img').css("width", ancho);
$('.hover img').css("width", ancho);
});
您可以在此库中收听该选项(以及更多)事件,
这里是 "append" 函数的示例,它是:
Triggered after item elements have been appended to the container
// jQuery
$container.on( 'append.infiniteScroll', function( event, response, path, items ) {
console.log( 'Loaded: ' + path );
});
// vanilla JS
infScroll.on( 'append', function( response, path, items ) {...});
是否可以在使用 infinite-scroll.js 库加载后调用函数?
我看到一个调用 init 的函数:
onInit: function() {
this.on( 'load', function() {
var ancho = parseFloat($('.imagen').innerWidth());
$('.normal img').css("width", ancho);
$('.hover img').css("width", ancho);
});
}
https://infinite-scroll.com/options.html#oninit
是否可以在加载内容后调用函数?
编辑
这是下面答案后的更新代码。
var inf = $('.col-trabajos').infiniteScroll({
path: '.nav-previous a',
append: '.article',
history: false,
hideNav: '.nav-links',
});
// callback
inf.on( 'append.infiniteScroll', function( event, response, path, items ) {
var ancho = $('.imagen').innerWidth();
$('.normal img').css("width", ancho);
$('.hover img').css("width", ancho);
});
您可以在此库中收听该选项(以及更多)事件,
这里是 "append" 函数的示例,它是:
Triggered after item elements have been appended to the container
// jQuery
$container.on( 'append.infiniteScroll', function( event, response, path, items ) {
console.log( 'Loaded: ' + path );
});
// vanilla JS
infScroll.on( 'append', function( response, path, items ) {...});