UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

24 lines (22 loc) 1.17 kB
"use strict"; var interfaces_1 = require('./interfaces'); 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