我正試圖將砌體元素添加到現有的元素。在砌體初始化之前顯示停止項目
但是,我現在擁有的是this - 這些項目在磚石被初始化之前顯示,然後在第二秒後跳到位置。我想讓他們隱藏起來,直到他們到位。
這是我使用追加砌體項目代碼(無限滾動的插件內):
$container.append(data);
$container.imagesLoaded(function()
{
$container.masonry('reloadItems').masonry();
});
這裏,它正在初始化:
$(document).ready(function()
{
$container = $('#container');
// initialize the masonry instance
$container.imagesLoaded(function(){
$container.masonry({
columnWidth: 1,
itemSelector: '.item',
transitionDuration: 0
});
});
$('#container').scrollPagination({
nop : 36, // The number of posts per scroll to be loaded
offset : 0, // Initial offset, begins at 0 in this case
error : 'No More Posts!', // When the user reaches the end this is the message that is
// displayed. You can change this if you want.
delay : 500, // When you scroll down the posts will load after a delayed amount of time.
// This is mainly for usability concerns. You can alter this as you see fit
scroll : true // The main bit, if set to false posts will not load as the user scrolls.
// but will still load if the user clicks.
});
});
UPDATE
根據Josh的回答,我現在的代碼如下所示:
$container.append(data);
$container.imagesLoaded(function()
{
$(".item").show();
$container.masonry('reloadItems').masonry();
});
而且我已將<class='hide'>
添加到商品代碼。
但是,當我刷新頁面時,現在沒有元素顯示出來。
我的意思是讓你隱藏剛剛進入頁面的項目。 你隱藏了一切,所以它永遠不會顯示。另外,做一個$('。item')。removeClass('hide');而不是 – Josh
這就是我遇到的問題 - 我如何僅僅提及新項目,而不是簡單地每個「- 」? –
Sebastian