Closed Meth0d-S closed 3 years ago
Yes, you can set the exactInput
argument to set
or setHandle
to true
.
I'm writing this calc.noUiSlider.set(this.value, true, true);
, but for some reason it still doesn't work
all my code:
var calc = document.querySelector('.calc-slider');
noUiSlider.create(calc, {
start: [100000],
connect: [true, false],
range: {
'min': [100000, 100000],
'50%': [1000000, 1000000],
'max': [20000000],
},
});
var calcValue = document.querySelector('.calc-input');
calc.noUiSlider.on('update', function (values, handle) {
calcValue.value = new Intl.NumberFormat().format(values[handle]);
// calcValue.value = values[handle]
var now = calc.noUiSlider.get();
var connect = document.querySelector('.noUi-connect')
var handler = document.querySelector('.noUi-handle')
var red = '#D30000'
var yellow = '#EFAD00'
var green = '#19C241'
if (now < 499999) {
connect.style.backgroundColor = red
handler.style.borderColor = red
}
if (now > 499999) {
connect.style.backgroundColor = yellow
handler.style.borderColor = yellow
}
if (now > 999999) {
connect.style.backgroundColor = green
handler.style.borderColor = green
}
});
calcValue.addEventListener('change', function () {
calc.noUiSlider.set(this.value, true, true);
});
I changed the update
event to slide
and everything worked. The question can be closed. Thanks
Glad you worked it out 👍
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I use noUiSlider with the 'step' parameter. Each step is equal to 100,000, 'range' = 1,000,000. When I enter a number in' stepSliderValueElement ' that is not a multiple of 100,000, it rounds the number to the nearest multiple. Is it possible to select a number that is not a multiple of 'step' with the 'step' parameter?