-
I am using Svelte, and I am using this slider for my project. Current situation: Issue: Possible solutions
I assume that 1 is not possible, 2 and 4 don't look as good UI-wise, 5 would be pretty difficult, and 3 seems the best but I'm wondering if there is a better solution? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @Nokocchi ... wow that's a pretty complicated setup which I don't fully understand the use-case. Next; Basically I think you have explored all the possibilities correctly. However, it is still not the ideal (frozen handles) situation. I'm actually curious if it's possible, and how to, implement a |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for the quick reply! I really appreciate it! :) Your REPL is very close to what I currently have. I have made a REPL myself though: https://svelte.dev/repl/8bd062807b954943bba0f9a1e2bbcb9e?version=4.2.0 The use case is that I am building a svelte app where the user can change colors of an image. One of the ways of changing colors is by using RGB/HSL sliders. So you select one of the colors, and then you can change the R value with a slider, the G value with a slider, and the B value with a slider. That all works well, and I only need one handle per slider. But I am currently implementing a new feature where you can pick multiple different colors at once, and change them all at once. In my REPL,, notice that each value corresponds to the R value of a color. I want to move them as a group to keep the proportions between the colors the same. This means that your REPL unfortunately doesn't fix my issue, as the distance between the slider handles don't always stay the same. But I like the way you coded it though! Edit2: I thought I had fixed it with preventDefault, but I just coded it wrong and the nullpointer exception somehow ended up resulting in the desired behavior.. Ignore my previous edits :( |
Beta Was this translation helpful? Give feedback.
-
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 basically intercept the function that decides whether to move the handle or not. If any of the nubs would be pulled out of the legal range, this function simply returns and does nothing. I haven't tested this in very much detail, so it might need some fine-tuning. But I can bind to the values array and it works as intended for my specific use case. Are you okay with me using a modifying version of your source code in my hobby project? I will give credit, and the project is entirely free to use and will not be used in any commercial way :) |
Beta Was this translation helpful? Give feedback.
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