同位素-在第一次加载中隐藏元素

Lau*_*aro 0 javascript jquery-isotope

按照有关无限滚动的说明,我能够从第2、3、4页等中隐藏新内容,直到完成加载然后进行动画处理。现在,我想达到相同的效果,但主要内容是首页。有什么帮助吗?我正在使用的代码:

<script>
    $(function(){
      var $container = $('#boxes');
      $container.imagesLoaded( function(){
        $container.isotope({
          itemSelector : '.box' 
        });
      });  
</script>

<script>
$('#boxes').isotope({ 
 // options
   itemSelector : '.box',
   layoutMode : 'masonry'
    masonry : {
          columnWidth : 325
        },
});
</script>

<script>
   $(function(){
             var $container = $('#boxes');
             $container.imagesLoaded(function(){
                 $container.isotope({
                     itemSelector: '.box'
                 });
             });
              $container.infinitescroll({
        navSelector  : '#navigation',   
        nextSelector : '#navigation a#next', 
        itemSelector : '.box',    

        loading: {
            finishedMsg: 'no more pages to load.',
            img: 'http://i.imgur.com/qkKy8.gif'
                 }
             },
             function(newElements){ 
                 var $newElems = jQuery( newElements ).hide()
                 console.log('Elements Retrieved:');
                 var $newElems = $(newElements);
                 $container.imagesLoaded(function(){
                     $newElems.fadeIn(); // fade in when ready
           $container.isotope('appended', $newElems, function(){console.log('Appended');});
                 });
             });
         });

  </script>
Run Code Online (Sandbox Code Playgroud)

是博客。提前致谢!

Sys*_*get 5

我的意思是-在您的CSS中

#container {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

默认情况下隐藏#container,因此最初不会显示;然后,在您的脚本中,您只需将

$container.show();
Run Code Online (Sandbox Code Playgroud)

在您想要显示它的地方;例如,当第一页的所有内容都已加载时,或者您希望第一次.show()您的#container时。这里简单的例子。