Skip to content

Commit

Permalink
added readme content
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Nov 14, 2010
1 parent 30585a5 commit b1df40b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README
@@ -0,0 +1,12 @@
jQuery Distribute Plugin

This plugin allows you to evenly distribute elements across the page whilst maintaining minimum and maximum margins between them.

Perfect for displaying a grid of images within a fluid layout like google images. For best affect call on page load and resize, for example:


$(window).resize(function(){
$('#search-results ol').distribute();
});

$('#search-results ol').distribute();
2 changes: 1 addition & 1 deletion jquery.distribute.js
Expand Up @@ -34,7 +34,7 @@
m = 0; // last in a row, dont give a margin.
}

$(this).css('margin-right', m + 'px');
$(this).css('margin-right', m + 'px').css('display', 'inline-block');
});
});

Expand Down
2 changes: 1 addition & 1 deletion jquery.distribute.min.js
Expand Up @@ -7,4 +7,4 @@
* @version 1.0
*/

(function($){$.fn.distribute=function(options){var defaults={margin:10,width:null};var options=$.extend(defaults,options);return this.each(function(){var totalWidth=$(this).width();var itemWidth=options.width?options.width:$(this).children(0).outerWidth();var perRow=Math.floor(totalWidth/(itemWidth+options.margin));var widthItemsOnRow=itemWidth*perRow;var marginsWidth=totalWidth-widthItemsOnRow;var newMargin=Math.floor(marginsWidth/(perRow-1))-4;$(this).children().each(function(index){var m=newMargin;if((index+1)%perRow==0&&index!==0){m=0}$(this).css('margin-right',m+'px')})})}})(jQuery);
(function($){$.fn.distribute=function(options){var defaults={margin:10,width:null};var options=$.extend(defaults,options);return this.each(function(){var totalWidth=$(this).width();var itemWidth=options.width?options.width:$(this).children(0).outerWidth();var perRow=Math.floor(totalWidth/(itemWidth+options.margin));var widthItemsOnRow=itemWidth*perRow;var marginsWidth=totalWidth-widthItemsOnRow;var newMargin=Math.floor(marginsWidth/(perRow-1))-4;$(this).children().each(function(index){var m=newMargin;if((index+1)%perRow==0&&index!==0){m=0}$(this).css('margin-right',m+'px').css('display','inline-block')})})}})(jQuery);

0 comments on commit b1df40b

Please sign in to comment.