office-ui-fabric-react
Version: 
Reusable React components for building experiences for Office 365.
26 lines (24 loc) • 1.37 kB
JavaScript
define(["require", "exports", "./interfaces"], function (require, exports, interfaces_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var SelectionLayout = (function () {
        function SelectionLayout(direction) {
            this._direction = direction;
        }
        SelectionLayout.prototype.getItemIndexAbove = function (focusIndex, items) {
            return (this._direction === interfaces_1.SelectionDirection.vertical) ? Math.max(0, focusIndex - 1) : focusIndex;
        };
        SelectionLayout.prototype.getItemIndexBelow = function (focusIndex, items) {
            return (this._direction === interfaces_1.SelectionDirection.vertical) ? Math.min(items.length - 1, focusIndex + 1) : focusIndex;
        };
        SelectionLayout.prototype.getItemIndexLeft = function (focusIndex, items) {
            return (this._direction === interfaces_1.SelectionDirection.vertical) ? focusIndex : Math.max(0, focusIndex - 1);
        };
        SelectionLayout.prototype.getItemIndexRight = function (focusIndex, items) {
            return (this._direction === interfaces_1.SelectionDirection.vertical) ? focusIndex : Math.min(items.length - 1, focusIndex + 1);
        };
        return SelectionLayout;
    }());
    exports.SelectionLayout = SelectionLayout;
});
//# sourceMappingURL=SelectionLayout.js.map