react-native-smooth-picker icon indicating copy to clipboard operation
react-native-smooth-picker copied to clipboard

Uncontrolled movement with fast scrolling in horizontal mode release mode

Open CodeShiva87 opened this issue 4 years ago • 2 comments

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}/>;
};

CodeShiva87 avatar Aug 16 '20 19:08 CodeShiva87

Hi, I was not able to reproduce your bug in release mode, can you update a gif or more details? Try to use the latest version 1.1.3 also.

rdhox avatar Aug 28 '20 09:08 rdhox

Hi, I was not able to reproduce your bug in release mode, can you update a gif or more details? Try to use the latest version 1.1.3 also.

Thanks. Looks like the issue is in the code below in handleChange: refPicker.current.scrollToIndex({ animated: true, index: index, viewOffset: -30, });

Works fine when I remove this. Not sure why it doesn't work properly in Release mode though.

CodeShiva87 avatar Sep 06 '20 19:09 CodeShiva87