Skip to content

How do I make the slider handles move as a group while obeying the min/max constraints? #113

Answered by Nokocchi
Nokocchi asked this question in Q&A
Discussion options

You must be logged in to vote

I did it! It works now.

I changed your source code a tiny bit to make it work, so I cannot make a REPL, but I will explain what I did.
I added an export variable by the name multiMoveMode, and then in the moveHandle() function, I added

    if (multiMoveMode) {
          let delta = value - values[index];
          let anyIllegalValues =
              values.filter((val) => {
                  let newVal = val + delta;
                  return newVal < min || max < newVal;
              }).length > 0;
          if (anyIllegalValues) {
              return value;
          } else {
              for (let i = 0; i < values.length; i++) {
                  values[i] += delta;
              }
…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@simeydotme
Comment options

@simeydotme
Comment options

@Nokocchi
Comment options

Answer selected by simeydotme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants