Skip to content

Commit 05f63a0

Browse files
committed
Ensure that slider values from nouislider are valid
According to the nouislider docs, values are float by default, and you must convert them as desired in the to function. It seems that Math.round is more appropriate than Math.floor - the slider value might be just below the appropriate value instead of just above.
1 parent da11b72 commit 05f63a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/controls/src/widget_int.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export abstract class BaseIntSliderView extends DescriptionView {
219219
direction: orientation === 'horizontal' ? 'ltr' : 'rtl',
220220
format: {
221221
from: (value: string): number => Number(value),
222-
to: (value: number): number => value,
222+
to: (value: number): number => this._validate_slide_value(value),
223223
},
224224
});
225225

@@ -285,7 +285,7 @@ export abstract class BaseIntSliderView extends DescriptionView {
285285
* and applying it to the other views on the page.
286286
*/
287287
_validate_slide_value(x: number): number {
288-
return Math.floor(x);
288+
return Math.round(x);
289289
}
290290

291291
$slider: any;

0 commit comments

Comments
 (0)