react-native-ruler-picker
react-native-ruler-picker copied to clipboard
RulerPicker can't handle negative values properly
Hello,
First of all, thank you very much for your work on RulerPicker. It has provided a ton of value to us.
Problem Description: The RulerPicker component does not handle negative values correctly. When using a range that includes negative numbers, the component resets to the initial value after reaching a certain positive value, instead of continuing to the maximum value.
Expected Behavior: The RulerPicker should smoothly scroll through the entire specified range, including negative values, without resetting or jumping to unexpected values.
Steps to Reproduce:
- Set up a React Native project with the RulerPicker component.
- Implement the RulerPicker with the following props:
<RulerPicker
min={-50}
max={150}
step={1}
fractionDigits={0}
initialValue={50}
onValueChange={(number) => console.log(number)}
unit="°F"
height={200}
/>
- Run the application and interact with the RulerPicker.
- Scroll the picker from the initial value (50°F) towards higher values.
- Observe that after reaching approximately 113°F, the picker resets back to the initial value (50°F) instead of continuing to 150°F.
Additional Information:
- The issue appears to be related to how the component calculates values, particularly when the range includes negative numbers.
- The problem likely stems from the
calculateCurrentValuefunction in the utils file, which may not account for ranges with negative values correctly.
https://github.com/user-attachments/assets/15843eee-7264-4208-8694-df62ef174129