react-native-timer-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 🍏
33 lines (30 loc) • 828 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAdjustedLimit = void 0;
const getAdjustedLimit = (limit, numberOfItems, interval) => {
const maxValue = (numberOfItems - 1) * interval;
if (!limit || !limit.max && !limit.min) {
return {
max: maxValue,
min: 0
};
}
// guard against limits that are out of bounds
const adjustedMaxLimit = limit.max ? Math.min(limit.max, maxValue) : maxValue;
const adjustedMinLimit = limit.min ? Math.max(limit.min, 0) : 0;
// guard against invalid limits
if (adjustedMaxLimit < adjustedMinLimit) {
return {
max: maxValue,
min: 0
};
}
return {
max: adjustedMaxLimit,
min: adjustedMinLimit
};
};
exports.getAdjustedLimit = getAdjustedLimit;
//# sourceMappingURL=getAdjustedLimit.js.map
;