slider
slider copied to clipboard
Fix floating-point arithmetic issues when props are decimals.
Consider the following case:
const value = 5.3;
const props = {
marks: {},
step: 0.05,
min: 0,
max: 5.3
};
I would expect the output of getClosestPoint to be 5.3. However, it returns 5.25.
This is because of floating point arithmetic issues with the function.
I've added a test case and taken a stab at figuring it out, making sure I continue to respect the Math.floor logic on maxSteps.
Codecov Report
Merging #619 into master will increase coverage by
0.43%. The diff coverage is100%.
@@ Coverage Diff @@
## master #619 +/- ##
==========================================
+ Coverage 95.4% 95.83% +0.43%
==========================================
Files 2 2
Lines 87 96 +9
Branches 29 30 +1
==========================================
+ Hits 83 92 +9
Misses 4 4
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/utils.js | 95.5% <100%> (+0.5%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 5ba4181...e4768ef. Read the comment docs.