本文介绍了jQuery masonry如何调用layoutComplete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下函数:
namespace.utils.pageReorder(feed,function(){
console .log('complete');
//做一些东西在这里没有重新排序已经完成
});
-------------
pageReorder:function(feed,callback){
feed.masonry 'reloadItems');
feed.masonry('layout');
callback();
},
我需要做的只是一旦砖石布局完成,调用回调。我知道masonry有以下方法,但不知道如何将其集成到我的函数。
msnry.on('layoutComplete' ,function(){
console.log('layout is complete,just once');
return true;
});
感谢
Pete
假设feed是一个jquery元素:
我发现它在布局之前注册事件监听器时最可靠。 feed.masonry({
isInitLayout:false,
transitionDuration:0,});
var msnry = feed.data('masonry');
msnry.on('layoutComplete',function(){
console.log('layout is complete,just once');
}
msnry.layout();
I have the following function:
namespace.utils.pageReorder(feed, function() {
console.log('complete');
// do some stuff here no reorder has completed
});
-------------
pageReorder: function(feed, callback) {
feed.masonry('reloadItems');
feed.masonry('layout');
callback();
},
What i need to be able to do is to only call the callback once the masonry layout has completed. I know masonry has the following method but im not sure how to integrate it into my function.
msnry.on( 'layoutComplete', function() {
console.log('layout is complete, just once');
return true;
});
ThanksPete
解决方案
I found it working most reliable when registering the event listener before layouting.
Assuming feed is a jquery element:
feed.masonry({
isInitLayout: false,
transitionDuration: 0,});
var msnry = feed.data('masonry');
msnry.on( 'layoutComplete', function() {
console.log('layout is complete, just once');
});
msnry.layout();
这篇关于jQuery masonry如何调用layoutComplete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 00:05