react-native-wheely icon indicating copy to clipboard operation
react-native-wheely copied to clipboard

Selected value skips after being selected

Open ikurowski opened this issue 2 years ago • 3 comments

Hello,

I noticed that sometimes when i select some value it skips from selected indicator. Like in this video:

https://user-images.githubusercontent.com/20643582/222527540-53486ae7-88e9-4450-b124-845f5ee18a48.mp4

For example, in the 9th second of the video skip occured. Next one in 20th.

My code:

       ...
       const [selectedIndex, setSelectedIndex] = useState(0);
       ...
        <WheelPicker
            selectedIndex={selectedIndex}
            options={wheelPickerNumbers} // wheelPickerNumbers - array with numbers as strings from 1 to 60
            onChange={index => {
              setSelectedIndex(index);
              updateTimeFunction(Number(wheelPickerNumbers[index]) * 60000);
            }}
            itemTextStyle={{...styles.numbers, color: colors.text}}
            selectedIndicatorStyle={{
              ...styles.selectedIndicatorStyle,
              backgroundColor: colors.primary,
            }}
            itemHeight={moderateScale(30)}
          />

I tested only on IOS. Thank you.

EDIT. When I change itemHeight to moderateScale(35), the picker works fine.

ikurowski avatar Mar 02 '23 19:03 ikurowski

I am facing the same issue.

c-goettert avatar Apr 03 '23 12:04 c-goettert

We are also using some scaling function, and it seems to be occurring if the item height is set to a non-integer (e.g. 43.5). For me itemHeight={Math.round(itemHeightVar)} did the trick.

c-goettert avatar Apr 03 '23 13:04 c-goettert

We are also using some scaling function, and it seems to be occurring if the item height is set to a non-integer (e.g. 43.5). For me itemHeight={Math.round(itemHeightVar)} did the trick.

That worked for me either. Thank you :)

ikurowski avatar Apr 12 '23 13:04 ikurowski