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

RulerPicker can't handle negative values properly

Open carloteran19 opened this issue 1 year ago • 0 comments

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:

  1. Set up a React Native project with the RulerPicker component.
  2. 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}
/>
  1. Run the application and interact with the RulerPicker.
  2. Scroll the picker from the initial value (50°F) towards higher values.
  3. 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 calculateCurrentValue function 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

carloteran19 avatar Oct 21 '24 18:10 carloteran19