是否可以在使用 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);
});
最佳答案
您可以在此库中收听该选项(以及更多)事件,
这是“追加”功能的示例:
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 ) {...});
关于javascript - 使用 infinite-scroll.js 库在内容加载后执行回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49065918/