Skip to content

Commit 6ecc925

Browse files
author
vvo
committed
fix(rangeSlider): step accepts a float value
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.
1 parent b1c555e commit 6ecc925

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/widgets/range-slider/__tests__/range-slider-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ describe('rangeSlider()', () => {
317317

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

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

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

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

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

346346
let state0 = helper.state;
347347
widget._refine(helper, stats, targetValue);

src/widgets/range-slider/range-slider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ function rangeSlider({
137137
_refine(helper, oldValues, newValues) {
138138
helper.clearRefinements(attributeName);
139139
if (newValues[0] > oldValues.min) {
140-
helper.addNumericRefinement(attributeName, '>=', Math.round(newValues[0]));
140+
helper.addNumericRefinement(attributeName, '>=', newValues[0]);
141141
}
142142
if (newValues[1] < oldValues.max) {
143-
helper.addNumericRefinement(attributeName, '<=', Math.round(newValues[1]));
143+
helper.addNumericRefinement(attributeName, '<=', newValues[1]);
144144
}
145145
helper.search();
146146
},

0 commit comments

Comments
 (0)