Advertisement
srikat

equalheight.js

Jul 3rd, 2013
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var currentTallest = 0,
  2.    currentRowStart = 0,
  3.    rowDivs = new Array(),
  4.    $el,
  5.    topPosition = 0;
  6.  
  7. jQuery(document).ready(function($) {
  8.   $('.edd_download').each(function() {
  9.  
  10.    $el = $(this);
  11.    topPostion = $el.position().top;
  12.  
  13.    if (currentRowStart != topPostion) {
  14.  
  15.      // we just came to a new row.  Set all the heights on the completed row
  16.      for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  17.        rowDivs[currentDiv].height(currentTallest);
  18.      }
  19.  
  20.      // set the variables for the new row
  21.      rowDivs.length = 0; // empty the array
  22.      currentRowStart = topPostion;
  23.      currentTallest = $el.height();
  24.      rowDivs.push($el);
  25.  
  26.    } else {
  27.  
  28.      // another div on the current row.  Add it to the list and check if it's taller
  29.      rowDivs.push($el);
  30.      currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
  31.  
  32.   }
  33.  
  34.   // do the last row
  35.    for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  36.      rowDivs[currentDiv].height(currentTallest);
  37.    }
  38.   })
  39. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement