@salient-sys/react-native-infinite-picker
Version:
A simple, flexible, performant duration picker for React Native apps 🔥 Great for timers, alarms and duration inputs ⏰🕰️⏳ Includes iOS-style haptic and audio feedback 🍏
37 lines (34 loc) • 878 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAdjustedLimit = void 0;
const getAdjustedLimit = variables => {
const {
limit,
numberOfItems
} = variables;
const maxIndex = numberOfItems - 1;
if (!limit || !limit.maxIndex && !limit.minIndex) {
return {
max: maxIndex,
min: 0
};
}
// guard against limits that are out of bounds
const adjustedMaxLimit = limit.maxIndex ? Math.min(limit.maxIndex, maxIndex) : maxIndex;
const adjustedMinLimit = limit.minIndex ? Math.max(limit.minIndex, 0) : 0;
// guard against invalid limits
if (adjustedMaxLimit < adjustedMinLimit) {
return {
max: maxIndex,
min: 0
};
}
return {
max: adjustedMaxLimit,
min: adjustedMinLimit
};
};
exports.getAdjustedLimit = getAdjustedLimit;
//# sourceMappingURL=getAdjustedLimit.js.map