@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 🍏
26 lines (25 loc) • 813 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getInitialScrollIndex = void 0;
const getInitialScrollIndex = variables => {
const {
disableInfiniteScroll,
initialValue,
numberOfItems,
padWithNItems,
pickerItems,
repeatValuesNTimes
} = variables;
let index = 0;
if (initialValue !== undefined) {
const indexOfInitialValue = pickerItems.findIndex(item => item.value === initialValue);
if (indexOfInitialValue !== -1) {
index = indexOfInitialValue;
}
}
return Math.max(numberOfItems * Math.floor(repeatValuesNTimes / 2) + (index + numberOfItems) % numberOfItems - (!disableInfiniteScroll ? padWithNItems : 0), 0);
};
exports.getInitialScrollIndex = getInitialScrollIndex;
//# sourceMappingURL=getInitialScrollIndex.js.map