I am currently working on a slider using noUi Slider and aiming for an elegant solution. To accommodate the large size of the handle, I expanded the base UI with extra values which are not allowed, causing the handle to jump back to the permitted values. To address this issue, I added plus and minus buttons where the restricted values are located.
However, I am facing a problem where I can't make the control symbols (plus/minus) disappear behind the handle when it is moved over them. They remain visible on top, and I am struggling to find a solution to hide them behind the handle. Any help or advice on this matter would be greatly appreciated.
Below is the code I have implemented (styles can be found on JSFiddle):
$(document).ready(function(){
var sliders = document.getElementById('red'),
input = document.getElementById('handle'),
sliderPlus = document.getElementById('slider-amount-plus'),
sliderMinus = document.getElementById('slider-amount-minus'),
termCur = 500;
noUiSlider.create(sliders, {
start: termCur,
step: 50,
connect: "lower",
range: {
'min': 0,
'max': 1100
},
pips: {
mode: 'values',
values: [100, 500, 1000],
density: 4.5
}
});
$('<div class="value">' + termCur + ' zł' + '</div>').appendTo($('.noUi-handle', sliders));
sliders.noUiSlider.on('change', function ( values, handle ) {
if ( values[handle] < 100 ) {
sliders.noUiSlider.set(100);
} else if ( values[handle] > 1000 ) {
sliders.noUiSlider.set(1000);
}
});
sliders.noUiSlider.on('update', function( values ) {
termCur = values;
if( termCur >= 100 && termCur <= 1000 ) {
$('.value', sliders).text(parseInt(termCur) + ' zł');}
});
sliderPlus.addEventListener('click', function(){
if(termCur < 1000) {
var setValue = parseInt(termCur) + 50;
sliders.noUiSlider.set(setValue);
}
});
sliderMinus.addEventListener('click', function(){
if(termCur > 100) {
var setValue = parseInt(termCur) - 50;
sliders.noUiSlider.set(setValue);
}
});
<div class="sliders" id="red">
<a class="controls-symbols slider-minus" id="slider-amount-minus"><i class="fa fa-minus"></i></a>
<a class="controls-symbols slider-plus" id="slider-amount-plus"><i class="fa fa-plus"></i></a>
</div>