Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. $(function(){
  2.  
  3. $.fn.randomize = function(childElem) {
  4. return this.each(function(){
  5. var $this = $(this);
  6. var elems = $this.children(childElem);
  7.  
  8. elems.sort(function(){return (Math.round(Math.random()) - 0.5); });
  9.  
  10. $this.remove(childElem);
  11.  
  12. for(var i=0; i < elems.length; i++)
  13. $this.append(elems[i]);
  14. })
  15. };
  16.  
  17. var $container = $("#container");
  18. $container.imagesLoaded(function(){
  19. $container.randomize(".item").masonry({
  20. itemSelector: '.item',
  21. columnWidth: function(containerWidth){
  22. return containerWidth / 4;
  23. }(),
  24. isAnimated: true
  25. });
  26. $(".item img.not-loaded").trigger("scroll");
  27. });
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement