Skip to content

Commit

Permalink
added coffeescript snippet to make all items the equal height
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Helin committed Jun 2, 2014
1 parent 0116742 commit df54a6c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions coffeescript/distribute_height/distribute_height.coffee
@@ -0,0 +1,22 @@
## Snippet to distribute heights on a couple of elements

# the wrap
$wrap = $('[data-distribute-height]')

# we want each wrap seperate
$wrap.each ->
maxHeight = 0
$items = $(this).find '.item'

# reset the height, so it can be recalculated
$items.height 'auto'

# check the height of each item, if it's bigger that the highest at that point, overwrite the maxHeight
$items.each ->
height = $(this).height()

if height > maxHeight
maxHeight = height

# set the height for all items
$items.height maxHeight

0 comments on commit df54a6c

Please sign in to comment.