Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Uncontrolled movement with fast scrolling in horizontal mode release mode #22

@CodeShiva87

Description

@CodeShiva87

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions