Skip to content

RulerPicker can't handle negative values properly #8

@carloteran19

Description

@carloteran19

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.
Issue.Ruler.Picker.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions