app/src/views/reflowableScrollview.js
/**
     * Helper function to return an array of arrays where each inner array contains 2 elements.
     * The first element represents the total gutter size in between each sequenceItem for a particular view.
     * The second element reprsents the total number of sequenceItems for a particular view.
     * @param {Array} sequenceItems represents a collection of renderables that the user passes in
     * @param {Number} direction X or Y scrolling
     * @param {Array} contextSize An array representing the width and height of window
     * @return {Array} returns an array of arrays
     */
Helper function to return an array of arrays where each inner array contains 2 elements.
The first element represents the total gutter size in between each sequenceItem for a particular view.
The second element reprsents the total number of sequenceItems for a particular view.
@param {Array} sequenceItems represents a collection of renderables that the user passes in
@param {Number} direction X or Y scrolling
@param {Array} contextSize An array representing the width and height of window
@return {Array} returns an array of arrays
Helper function to return an array of arrays where each inner array contains 2 elements . The first element represents the total gutter size in between each sequenceItem for a particular view . The second element reprsents the total number of sequenceItems for a particular view . @param { Array } sequenceItems represents a collection of renderables that the user passes in @param { Number } direction X or Y scrolling @param { Array } contextSize An array representing the width and height of window @return { Array } returns an array of arrays
function _calculateGutterInfo(sequenceItems, direction, contextSize) {
        var offsetDirection = (direction === 0 ? 1 : 0);
        var accumulatedSize = 0;
        var numSequenceItems = 0;
        var gutterInfo = [];
        var totalGutter;
        var sequenceItem;
        var currentSequenceItemSize;
        for (var i = 0; i < sequenceItems.length; i += 1) {
            sequenceItem = sequenceItems[i];
            currentSequenceItemSize = sequenceItem.getSize()[offsetDirection];
            if (accumulatedSize + currentSequenceItemSize <= contextSize[offsetDirection]) {
                accumulatedSize += currentSequenceItemSize;
                numSequenceItems += 1;
                if (i === sequenceItems.length - 1) {
                    totalGutter = contextSize[offsetDirection] - accumulatedSize;
                    gutterInfo.push( [Math.floor(totalGutter / (numSequenceItems - 1)), numSequenceItems] );
                }
            } 
            else {
                totalGutter = contextSize[offsetDirection] - accumulatedSize;
                gutterInfo.push( [Math.floor(totalGutter / (numSequenceItems - 1)), numSequenceItems] );
                accumulatedSize = 0;
                numSequenceItems = 0;
                accumulatedSize += currentSequenceItemSize;
                numSequenceItems += 1;
            }
        }
        return gutterInfo; 
    }
function _calculateGutterInfo ( sequenceItems , direction , contextSize ) { var offsetDirection = ( direction === 0 ? 1 : 0 ) ; var accumulatedSize = 0 ; var numSequenceItems = 0 ; var gutterInfo = [ ] ; var totalGutter ; var sequenceItem ; var currentSequenceItemSize ; for ( var i = 0 ; i < sequenceItems . length ; i += 1 ) { sequenceItem = sequenceItems [ i ] ; currentSequenceItemSize = sequenceItem . getSize ( ) [ offsetDirection ] ; if ( accumulatedSize + currentSequenceItemSize <= contextSize [ offsetDirection ] ) { accumulatedSize += currentSequenceItemSize ; numSequenceItems += 1 ; if ( i === sequenceItems . length - 1 ) { totalGutter = contextSize [ offsetDirection ] - accumulatedSize ; gutterInfo . push ( [ Math . floor ( totalGutter / ( numSequenceItems - 1 ) ) , numSequenceItems ] ) ; } } else { totalGutter = contextSize [ offsetDirection ] - accumulatedSize ; gutterInfo . push ( [ Math . floor ( totalGutter / ( numSequenceItems - 1 ) ) , numSequenceItems ] ) ; accumulatedSize = 0 ; numSequenceItems = 0 ; accumulatedSize += currentSequenceItemSize ; numSequenceItems += 1 ; } } return gutterInfo ; }
Helper function to return an array of arrays where each inner array contains 2 elements.
Helper function to return an array of arrays where each inner array contains 2 elements .
// 'this' will be an instance of reflowableScrollview // for the last view in the viewSequence, there may be less items than the other views // reset configurations for each new view in the viewSequence // [[total gutter / (number of items - 1), number of items]] 