Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update connect option #1269

Open
jamal-tmam opened this issue Apr 17, 2024 · 0 comments
Open

Update connect option #1269

jamal-tmam opened this issue Apr 17, 2024 · 0 comments

Comments

@jamal-tmam
Copy link

jamal-tmam commented Apr 17, 2024

I need to update connect option but is not working. Following is the code.
What I am trying to achieve here is that the range is from -5 to 5. and for the values greater than 0 will have connect option set to upper and color blue and for values less than 0 will connect option set to lower and color red.

Questions:

  1. How to make this updateOptions to work.
  2. Is there a better way to achieve what I want?
slider.noUiSlider.on("change", function (values, handle) {
    let progressValue = parseInt(values[handle]);

   if (progressValue < 0) {
        slider.noUiSlider.updateOptions({
            connect: 'lower'
        });

        slider.querySelector(".noUi-connect").style.backgroundColor = 'red'; // Set the slider track color to red for negative values
  } else if (progressValue > 0) {
        slider.noUiSlider.updateOptions({
            connect: 'upper'
        });
              
       slider.querySelector(".noUi-connect").style.backgroundColor = 'green'; // Set the slider track color to green for positive values
  } else {
       slider.querySelector(".noUi-connect").style.backgroundColor = 'transparent'; // Remove background color if the value is 0
  }
});

Following are the screenshots of examples what I want to achieve.

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant