@coreui/react
Version:
UI Components Library for React.js
20 lines (16 loc) • 617 B
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var getNextActiveElement = function (list, activeElement, shouldGetNext, isCycleAllowed) {
var listLength = list.length;
var index = list.indexOf(activeElement);
if (index === -1) {
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
}
index += shouldGetNext ? 1 : -1;
{
index = (index + listLength) % listLength;
}
return list[Math.max(0, Math.min(index, listLength - 1))];
};
exports.default = getNextActiveElement;
//# sourceMappingURL=getNextActiveElement.js.map
;