improve pip classList add/remove with no intermediary variable

This commit is contained in:
Jacob Overgaard
2022-09-21 15:37:57 +02:00
parent 65d065fb54
commit 348f3e71ea
2 changed files with 4 additions and 18 deletions

View File

@@ -322,20 +322,13 @@ For extra details about options and events take a look here: https://refreshless
});
}
function setUpActivePipsHandling() {
let activePip = [null, null];
sliderInstance.noUiSlider.on('update', function (values,handle) {
if(activePip[handle]){
activePip[handle].classList.remove("noUi-value-active");
}
sliderInstance.querySelectorAll('.noUi-value').forEach(pip => {
pip.classList.remove("noUi-value-active");
if (Number(values[handle]) === Number(pip.getAttribute('data-value'))) {
activePip[handle] = pip;
pip.classList.add("noUi-value-active");
}
});
if (activePip[handle]) {
activePip[handle].classList.add("noUi-value-active");
}
});
}
function addPipClickHandler(){

View File

@@ -54,20 +54,13 @@ angular.module("umbraco.install").controller("Umbraco.Install.UserController", f
const pips = consentSlider.querySelectorAll('.noUi-value');
let activePip = [null, null];
consentSlider.noUiSlider.on('update', function (values,handle) {
if(activePip[handle]){
activePip[handle].classList.remove("noUi-value-active");
}
consentSlider.querySelectorAll('.noUi-value').forEach(pip => {
pip.classList.remove("noUi-value-active");
if (Number(values[handle]) === Number(pip.getAttribute('data-value'))) {
activePip[handle] = pip;
pip.classList.add("noUi-value-active");
}
});
if (activePip[handle]) {
activePip[handle].classList.add("noUi-value-active");
}
});
$(consentSlider).on('$destroy', function () {