I'm facing this issue only in release mode that the smooth picker moves uncontrollably in horizontal mode with fast scrolling.
Not able to reproduce this in Debug mode and hence not able to solve it. Scrolling stops abruptly after some time or when I close the App and restart.
"react-native-smooth-picker": "^1.0.2",
<SmoothPicker
initialScrollToIndex={selected}
refFlatList={refPicker}
keyExtractor={(_, index) => index.toString()}
horizontal={true}
scrollAnimation
showsHorizontalScrollIndicator={false}
data={constants.MyArray}
renderItem={option => ItemToRender(option, selected, false)}
onSelected={({ item, index }) => handleChange(index)}
style={{backgroundColor: 'white', paddingLeft: 5, paddingRight: 5}}
/>
function handleChange(index) {
setSelected(index);
refPicker.current.scrollToIndex({
animated: true,
index: index,
viewOffset: -30,
});
}
const ItemToRender = ({item, index}, indexSelected, vertical) => {
const selected = index === indexSelected;
const gap = Math.abs(index - indexSelected);
let opacity = opacities[gap];
if (gap > 3) {
opacity = opacities[4];
}
let fontSize = sizeText[gap];
if (gap > 1) {
fontSize = sizeText[2];
}
return <Item opacity={opacity} selected={selected} vertical={vertical} fontSize={fontSize} name={item}/>;
};