Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected value skips after being selected #49

Open
ikurowski opened this issue Mar 2, 2023 · 3 comments
Open

Selected value skips after being selected #49

ikurowski opened this issue Mar 2, 2023 · 3 comments

Comments

@ikurowski
Copy link

ikurowski commented Mar 2, 2023

Hello,

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

Simulator.Screen.Recording.-.iPhone.14.-.2023-03-02.at.20.01.32.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.

@c-goettert
Copy link

I am facing the same issue.

@c-goettert
Copy link

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.

@ikurowski
Copy link
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants