2013-04-22 54 views
0

我在我的网站上使用jQuery Isotope加载图像墙。我的工作正常,但我想添加一些额外的东西,但我找不到任何东西在他们的网站上做到这一点...jquery isotope在窗口上随机随机调整大小

当浏览器窗口调整大小时,我希望它窒息,因为它重新排序图片。

可以这样做吗?

这是我到目前为止有:

(function($) { 
    $(document).ready(function() { 

    var $container = $('#isotope-container'); 

    $container.isotope({ 
    itemSelector: '.isotope-element', 
    sortBy : 'random' // THIS IS NOT WORKING TO SORT 
    }); 

    var $optionSets = $('#isotope-options .option-set'), 
     $optionLinks = $optionSets.find('a'); 

     $optionLinks.click(function(){ 

     var $this = $(this); 
     // don't proceed if already selected 
     if ($this.hasClass('selected')) { 
      return false; 
     } 
     var $optionSet = $this.parents('.option-set'); 
     $optionSet.find('.selected').removeClass('selected'); 
     $this.addClass('selected'); 

     var options = {}, 
      key = $optionSet.attr('data-option-key'), 
      value = $this.attr('data-option-value'); 
     // parse 'false' as false boolean 
     value = value === 'false' ? false : value; 
     options[ key ] = value; 
     if (key === 'layoutMode' && typeof changeLayoutMode === 'function') { 
      // changes in layout modes need extra logic 
      changeLayoutMode($this, options) 
     } else { 
      // otherwise, apply new options 
      $container.isotope(options); 
     } 

     return false; 
     }); 

     $('.isotope-element img').each(function(){ 
     var $this = $(this); 
     setTimeout(function(){ 
      $this.fadeIn(Math.floor(Math.random()*1500)); 
     }, Math.floor(Math.random()*1500)); 
    } 
); 
}); 

})(jQuery); 

任何帮助,这将是非常赞赏。

感谢 Ç

回答

2

对不起,我看着这一点越来越实际测试过这一次:) 试试这个:

$(window).resize(function() { 
    $container.isotope('shuffle', function() {}); 
}); 
+0

http://jsfiddle.net/apaul34208/SsFGy/ 3 /看起来像是有效的。 – apaul 2013-04-27 17:45:08

+0

完美,非常感谢! – Cybercampbell 2013-04-28 23:35:50