js/components/matrix.js
function() {
        var gutter = this.options.gutter,
            items = this.matrix,
            item,
            span,
            dir = this.options.rtl ? 'right' : 'left',
            y = [], // The top position values indexed by column
            c = 0, // Current column in the loop
            h = 0, // Smallest height column
            i, // Items loop counter
            l, // Items length
            s, // Current span column in the loop
            top,
            pos = { margin: 0, position: 'absolute' };

        for (i = 0; i < this.colCount; i++) {
            y.push(0);
        }

        for (i = 0, l = items.length; i < l; i++) {
            item = items[i];
            span = item.span;

            // Place the item in the smallest column
            h = -1;

            for (s = 0; s < this.colCount; s++) {
                if (h === -1 || y[s] < h) {
                    h = y[s];
                    c = s;
                }
            }

            // If the item extends too far out, move it to the next column
            // Or if the last column has been reached
            if ((c >= this.colCount) || ((span + c) > this.colCount)) {
                c = 0;
            }

            // Item spans a column or multiple columns
            if (span) {
                top = 0;

                // If the item spans multiple columns
                // Get the largest height from the previous row
                for (s = 0; s < span; s++) {
                    if (y[c + s] > top) {
                        top = y[c + s];
                    }
                }

                // Position the item
                pos.top = top;
                pos[dir] = (this.colWidth + gutter) * c;
                pos.width = ((this.colWidth + gutter) * span) - gutter;

                item.item.css(pos).reveal();

                // Loop again to add the value to each columns Y top value
                // This must be done after positioning so we can calculate a new size
                for (s = 0; s < span; s++) {
                    y[c + s] = item.item.outerHeight() + gutter + top;
                }
            }

            this.colHeights[c] = y[c];

            c++;
        }

        // Set height of wrapper
        this.element.css('height', Math.max.apply(Math, y));
    }
function() {
        var gutter = this.options.gutter,
            items = this.matrix,
            item,
            span,
            dir = this.options.rtl ? 'right' : 'left',
            y = [], // The top position values indexed by column
            c = 0, // Current column in the loop
            h = 0, // Smallest height column
            i, // Items loop counter
            l, // Items length
            s, // Current span column in the loop
            top,
            pos = { margin: 0, position: 'absolute' };

        for (i = 0; i < this.colCount; i++) {
            y.push(0);
        }

        for (i = 0, l = items.length; i < l; i++) {
            item = items[i];
            span = item.span;

            // Place the item in the smallest column
            h = -1;

            for (s = 0; s < this.colCount; s++) {
                if (h === -1 || y[s] < h) {
                    h = y[s];
                    c = s;
                }
            }

            // If the item extends too far out, move it to the next column
            // Or if the last column has been reached
            if ((c >= this.colCount) || ((span + c) > this.colCount)) {
                c = 0;
            }

            // Item spans a column or multiple columns
            if (span) {
                top = 0;

                // If the item spans multiple columns
                // Get the largest height from the previous row
                for (s = 0; s < span; s++) {
                    if (y[c + s] > top) {
                        top = y[c + s];
                    }
                }

                // Position the item
                pos.top = top;
                pos[dir] = (this.colWidth + gutter) * c;
                pos.width = ((this.colWidth + gutter) * span) - gutter;

                item.item.css(pos).reveal();

                // Loop again to add the value to each columns Y top value
                // This must be done after positioning so we can calculate a new size
                for (s = 0; s < span; s++) {
                    y[c + s] = item.item.outerHeight() + gutter + top;
                }
            }

            this.colHeights[c] = y[c];

            c++;
        }

        // Set height of wrapper
        this.element.css('height', Math.max.apply(Math, y));
    }
function ( ) { var gutter = this . options . gutter , items = this . matrix , item , span , dir = this . options . rtl ? 'right' : 'left' , y = [ ] , // The top position values indexed by column c = 0 , // Current column in the loop h = 0 , // Smallest height column i , // Items loop counter l , // Items length s , // Current span column in the loop top , pos = { margin : 0 , position : 'absolute' } ; for ( i = 0 ; i < this . colCount ; i ++ ) { y . push ( 0 ) ; } for ( i = 0 , l = items . length ; i < l ; i ++ ) { item = items [ i ] ; span = item . span ; // Place the item in the smallest column h = - 1 ; for ( s = 0 ; s < this . colCount ; s ++ ) { if ( h === - 1 || y [ s ] < h ) { h = y [ s ] ; c = s ; } } // If the item extends too far out, move it to the next column // Or if the last column has been reached if ( ( c >= this . colCount ) || ( ( span + c ) > this . colCount ) ) { c = 0 ; } // Item spans a column or multiple columns if ( span ) { top = 0 ; // If the item spans multiple columns // Get the largest height from the previous row for ( s = 0 ; s < span ; s ++ ) { if ( y [ c + s ] > top ) { top = y [ c + s ] ; } } // Position the item pos . top = top ; pos [ dir ] = ( this . colWidth + gutter ) * c ; pos . width = ( ( this . colWidth + gutter ) * span ) - gutter ; item . item . css ( pos ) . reveal ( ) ; // Loop again to add the value to each columns Y top value // This must be done after positioning so we can calculate a new size for ( s = 0 ; s < span ; s ++ ) { y [ c + s ] = item . item . outerHeight ( ) + gutter + top ; } } this . colHeights [ c ] = y [ c ] ; c ++ ; } // Set height of wrapper this . element . css ( 'height' , Math . max . apply ( Math , y ) ) ; }
Loop through the items in each column and position them absolutely.

@private
Loop through the items in each column and position them absolutely .