Skip to content

Commit

Permalink
fix(rangeSlider): step accepts a float value
Browse files Browse the repository at this point in the history
Before this commit we were not able to use float values for step, to
be able to have a slider with float values.

Rounding was introduced when fixing
#477.

Now that step = 1 by default we do not need rounding automatically. If
the user is careful about all the other widgets using the same
attribute to only refine rounded values then he's fine.
  • Loading branch information
vvo committed Apr 1, 2016
1 parent b1c555e commit 6ecc925
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/widgets/range-slider/__tests__/range-slider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ describe('rangeSlider()', () => {

it('calls the refinement functions if refined with min+1', () => {
let stats = results.disjunctiveFacets[0].stats;
let targetValue = Math.floor(stats.min) + 1;
let targetValue = stats.min + 1;

let state0 = helper.state;
widget._refine(helper, stats, [targetValue, stats.max]);
Expand All @@ -329,7 +329,7 @@ describe('rangeSlider()', () => {

it('calls the refinement functions if refined with max-1', () => {
let stats = results.disjunctiveFacets[0].stats;
let targetValue = Math.ceil(stats.max) - 1;
let targetValue = stats.max - 1;

let state0 = helper.state;
widget._refine(helper, stats, [stats.min, targetValue]);
Expand All @@ -341,7 +341,7 @@ describe('rangeSlider()', () => {

it('calls the refinement functions if refined with min+1 and max-1', () => {
let stats = results.disjunctiveFacets[0].stats;
let targetValue = [Math.floor(stats.min) + 1, Math.ceil(stats.max) - 1];
let targetValue = [stats.min + 1, stats.max - 1];

let state0 = helper.state;
widget._refine(helper, stats, targetValue);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/range-slider/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ function rangeSlider({
_refine(helper, oldValues, newValues) {
helper.clearRefinements(attributeName);
if (newValues[0] > oldValues.min) {
helper.addNumericRefinement(attributeName, '>=', Math.round(newValues[0]));
helper.addNumericRefinement(attributeName, '>=', newValues[0]);
}
if (newValues[1] < oldValues.max) {
helper.addNumericRefinement(attributeName, '<=', Math.round(newValues[1]));
helper.addNumericRefinement(attributeName, '<=', newValues[1]);
}
helper.search();
},
Expand Down

0 comments on commit 6ecc925

Please sign in to comment.