UNPKG

@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 🍏

30 lines (28 loc) 725 B
export 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 }; }; //# sourceMappingURL=getAdjustedLimit.js.map