office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
23 lines (22 loc) • 1.26 kB
JavaScript
define(["require", "exports", './interfaces'], function (require, exports, interfaces_1) {
"use strict";
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;
});