dist/famous-flex.js
function TabBarLayout(context, options) {

        // Prepare data
        size = context.size;
        direction = context.direction;
        revDirection = direction ? 0 : 1;
        spacing = options.spacing || 0;
        items = context.get('items');
        spacers = context.get('spacers');
        margins = LayoutUtility.normalizeMargins(options.margins);
        zIncrement = options.zIncrement || 2;
        set.size[0] = context.size[0];
        set.size[1] = context.size[1];
        set.size[revDirection] -= (margins[1 - revDirection] + margins[3 - revDirection]);
        set.translate[0] = 0;
        set.translate[1] = 0;
        set.translate[2] = zIncrement;
        set.translate[revDirection] = margins[direction ? 3 : 0];
        set.align[0] = 0;
        set.align[1] = 0;
        set.origin[0] = 0;
        set.origin[1] = 0;

        // When no item-size specified, spread all items
        // out equally over the full width/height, taking into
        // account margins & spacing
        offset = direction ? margins[0] : margins[3];
        sizeLeft = size[direction] - (offset + (direction ? margins[2] : margins[1]));
        sizeLeft -= ((items.length - 1) * spacing);
        for (var i = 0; i < items.length; i++) {

            // Calculate item size
            if (options.itemSize === undefined) {
                nodeSize = Math.round(sizeLeft / (items.length - i));
            }
            else {
                nodeSize = (options.itemSize === true) ? context.resolveSize(items[i], size)[direction] : options.itemSize;
            }

            // Calculate length used
            set.scrollLength = nodeSize;
            if (i === 0) {
                set.scrollLength += direction ? margins[0] : margins[3];
            }
            if (i === (items.length - 1)) {
                set.scrollLength += direction ? margins[2] : margins[1];
            }
            else {
                set.scrollLength += spacing;
            }

            // Position item
            set.size[direction] = nodeSize;
            set.translate[direction] = offset;
            context.set(items[i], set);
            offset += nodeSize;
            sizeLeft -= nodeSize;

            // Place selected item overlay
            if (i === options.selectedItemIndex) {
                set.scrollLength = 0;
                set.translate[direction] += (nodeSize / 2);
                set.translate[2] = zIncrement * 2;
                set.origin[direction] = 0.5;
                context.set('selectedItemOverlay', set);
                set.origin[direction] = 0;
                set.translate[2] = zIncrement;
            }

            // Position spacer (optional)
            if (i < (items.length - 1)) {
                if (spacers && (i < spacers.length)) {
                    set.size[direction] = spacing;
                    set.translate[direction] = offset;
                    context.set(spacers[i], set);
                }
                offset += spacing;
            }
            else {
                offset += direction ? margins[2] : margins[1];
            }
        }

        // Set background
        set.scrollLength = 0;
        set.size[0] = size[0];
        set.size[1] = size[1];
        set.size[direction] = size[direction];
        set.translate[0] = 0;
        set.translate[1] = 0;
        set.translate[2] = 0;
        set.translate[direction] = 0;
        context.set('background', set);
    }
function TabBarLayout(context, options) {

        // Prepare data
        size = context.size;
        direction = context.direction;
        revDirection = direction ? 0 : 1;
        spacing = options.spacing || 0;
        items = context.get('items');
        spacers = context.get('spacers');
        margins = LayoutUtility.normalizeMargins(options.margins);
        zIncrement = options.zIncrement || 2;
        set.size[0] = context.size[0];
        set.size[1] = context.size[1];
        set.size[revDirection] -= (margins[1 - revDirection] + margins[3 - revDirection]);
        set.translate[0] = 0;
        set.translate[1] = 0;
        set.translate[2] = zIncrement;
        set.translate[revDirection] = margins[direction ? 3 : 0];
        set.align[0] = 0;
        set.align[1] = 0;
        set.origin[0] = 0;
        set.origin[1] = 0;

        // When no item-size specified, spread all items
        // out equally over the full width/height, taking into
        // account margins & spacing
        offset = direction ? margins[0] : margins[3];
        sizeLeft = size[direction] - (offset + (direction ? margins[2] : margins[1]));
        sizeLeft -= ((items.length - 1) * spacing);
        for (var i = 0; i < items.length; i++) {

            // Calculate item size
            if (options.itemSize === undefined) {
                nodeSize = Math.round(sizeLeft / (items.length - i));
            }
            else {
                nodeSize = (options.itemSize === true) ? context.resolveSize(items[i], size)[direction] : options.itemSize;
            }

            // Calculate length used
            set.scrollLength = nodeSize;
            if (i === 0) {
                set.scrollLength += direction ? margins[0] : margins[3];
            }
            if (i === (items.length - 1)) {
                set.scrollLength += direction ? margins[2] : margins[1];
            }
            else {
                set.scrollLength += spacing;
            }

            // Position item
            set.size[direction] = nodeSize;
            set.translate[direction] = offset;
            context.set(items[i], set);
            offset += nodeSize;
            sizeLeft -= nodeSize;

            // Place selected item overlay
            if (i === options.selectedItemIndex) {
                set.scrollLength = 0;
                set.translate[direction] += (nodeSize / 2);
                set.translate[2] = zIncrement * 2;
                set.origin[direction] = 0.5;
                context.set('selectedItemOverlay', set);
                set.origin[direction] = 0;
                set.translate[2] = zIncrement;
            }

            // Position spacer (optional)
            if (i < (items.length - 1)) {
                if (spacers && (i < spacers.length)) {
                    set.size[direction] = spacing;
                    set.translate[direction] = offset;
                    context.set(spacers[i], set);
                }
                offset += spacing;
            }
            else {
                offset += direction ? margins[2] : margins[1];
            }
        }

        // Set background
        set.scrollLength = 0;
        set.size[0] = size[0];
        set.size[1] = size[1];
        set.size[direction] = size[direction];
        set.translate[0] = 0;
        set.translate[1] = 0;
        set.translate[2] = 0;
        set.translate[direction] = 0;
        context.set('background', set);
    }
Layout function