function _layoutLine(next, endReached) {
        if (!lineNodes.length) {
            return 0;
        }

        // Determine size of the line
        var i;
        var lineSize = [0, 0];
        var lineNode;
        for (i = 0; i < lineNodes.length; i++) {
            lineSize[direction] = Math.max(lineSize[direction], lineNodes[i].size[direction]);
            lineSize[lineDirection] += ((i > 0) ? spacing[lineDirection] : 0) + lineNodes[i].size[lineDirection];
        }

        // Layout nodes from left to right or top to bottom
        var justifyOffset = justify[lineDirection] ? ((lineLength - lineSize[lineDirection]) / (lineNodes.length * 2)) : 0;
        var lineOffset = (direction ? margins[3] : margins[0]) + justifyOffset;
        var scrollLength;
        for (i = 0; i < lineNodes.length; i++) {
            lineNode = lineNodes[i];
            var translate = [0, 0, 0];
            translate[lineDirection] = lineOffset;
            translate[direction] = next ? offset : (offset - (lineSize[direction]));
            scrollLength = 0;
            if (i === 0) {
                scrollLength = lineSize[direction];
                if (endReached && ((next && !alignment) || (!next && alignment))) {
                    scrollLength += direction ? (margins[0] + margins[2]) : (margins[3] + margins[1]);
                }
                else {
                    scrollLength += spacing[direction];
                }
            }
            lineNode.set = {
                size: lineNode.size,
                translate: translate,
                scrollLength: scrollLength
            };
            lineOffset += lineNode.size[lineDirection] + spacing[lineDirection] + (justifyOffset * 2);
        }

        // Set nodes
        for (i = 0; i < lineNodes.length; i++) {
            lineNode = next ? lineNodes[i] : lineNodes[(lineNodes.length - 1) - i];
            context.set(lineNode.node, lineNode.set);
        }

        // Prepare for next line
        lineNodes = [];
        return lineSize[direction] + spacing[direction];
    }
function _layoutLine(next, endReached) {
        if (!lineNodes.length) {
            return 0;
        }

        
        var i;
        var lineSize = [0, 0];
        var lineNode;
        for (i = 0; i < lineNodes.length; i++) {
            lineSize[direction] = Math.max(lineSize[direction], lineNodes[i].size[direction]);
            lineSize[lineDirection] += ((i > 0) ? spacing[lineDirection] : 0) + lineNodes[i].size[lineDirection];
        }

        
        var justifyOffset = justify[lineDirection] ? ((lineLength - lineSize[lineDirection]) / (lineNodes.length * 2)) : 0;
        var lineOffset = (direction ? margins[3] : margins[0]) + justifyOffset;
        var scrollLength;
        for (i = 0; i < lineNodes.length; i++) {
            lineNode = lineNodes[i];
            var translate = [0, 0, 0];
            translate[lineDirection] = lineOffset;
            translate[direction] = next ? offset : (offset - (lineSize[direction]));
            scrollLength = 0;
            if (i === 0) {
                scrollLength = lineSize[direction];
                if (endReached && ((next && !alignment) || (!next && alignment))) {
                    scrollLength += direction ? (margins[0] + margins[2]) : (margins[3] + margins[1]);
                }
                else {
                    scrollLength += spacing[direction];
                }
            }
            lineNode.set = {
                size: lineNode.size,
                translate: translate,
                scrollLength: scrollLength
            };
            lineOffset += lineNode.size[lineDirection] + spacing[lineDirection] + (justifyOffset * 2);
        }

        
        for (i = 0; i < lineNodes.length; i++) {
            lineNode = next ? lineNodes[i] : lineNodes[(lineNodes.length - 1) - i];
            context.set(lineNode.node, lineNode.set);
        }

        
        lineNodes = [];
        return lineSize[direction] + spacing[direction];
    }
function _layoutLine ( next , endReached ) { if ( ! lineNodes . length ) { return 0 ; } // Determine size of the line var i ; var lineSize = [ 0 , 0 ] ; var lineNode ; for ( i = 0 ; i < lineNodes . length ; i ++ ) { lineSize [ direction ] = Math . max ( lineSize [ direction ] , lineNodes [ i ] . size [ direction ] ) ; lineSize [ lineDirection ] += ( ( i > 0 ) ? spacing [ lineDirection ] : 0 ) + lineNodes [ i ] . size [ lineDirection ] ; } // Layout nodes from left to right or top to bottom var justifyOffset = justify [ lineDirection ] ? ( ( lineLength - lineSize [ lineDirection ] ) / ( lineNodes . length * 2 ) ) : 0 ; var lineOffset = ( direction ? margins [ 3 ] : margins [ 0 ] ) + justifyOffset ; var scrollLength ; for ( i = 0 ; i < lineNodes . length ; i ++ ) { lineNode = lineNodes [ i ] ; var translate = [ 0 , 0 , 0 ] ; translate [ lineDirection ] = lineOffset ; translate [ direction ] = next ? offset : ( offset - ( lineSize [ direction ] ) ) ; scrollLength = 0 ; if ( i === 0 ) { scrollLength = lineSize [ direction ] ; if ( endReached && ( ( next && ! alignment ) || ( ! next && alignment ) ) ) { scrollLength += direction ? ( margins [ 0 ] + margins [ 2 ] ) : ( margins [ 3 ] + margins [ 1 ] ) ; } else { scrollLength += spacing [ direction ] ; } } lineNode . set = { size : lineNode . size , translate : translate , scrollLength : scrollLength } ; lineOffset += lineNode . size [ lineDirection ] + spacing [ lineDirection ] + ( justifyOffset * 2 ) ; } // Set nodes for ( i = 0 ; i < lineNodes . length ; i ++ ) { lineNode = next ? lineNodes [ i ] : lineNodes [ ( lineNodes . length - 1 ) - i ] ; context . set ( lineNode . node , lineNode . set ) ; } // Prepare for next line lineNodes = [ ] ; return lineSize [ direction ] + spacing [ direction ] ; }
Lays out the renderables in a single line. Taking into account
the following variables:
- true-size
- margins
- spacing
- justify
- center align
Lays out the renderables in a single line . Taking into account the following variables : - true - size - margins - spacing - justify - center align