Closed marcofugaro closed 4 years ago
Absolutely. I think I'd rather make this LogSlider
than Slider({type: 'log'})
. These things tend to bring in lots of corner cases and make other things (like default ranges) subtly incorrect or logic-branchy when it'd really be easier and more concise to just separate them. (In fact, I don't use control-panel's log slider because I think my implementation has a couple annoying bugs I just haven't bothered to fix 😬) What's your opinion, @marcofugaro?
Alternatively, I maybe wouldn't mind a shorthand of type: 'log' with a more explicit way to specify it:
mapping: Math.log, inverseMapping: Math.exp` so that you can just be explicit about exactly how it's mapped and perform your own mapping.
That's a great idea! Way more flexible, so the default would be something like:
mappingFunction: x => x
Or just mapping like you said.
Also what do you mean by inverseMapping
? For when the slider goes the inverse way?
If you don't have a mapping that defines both directions, you can move a slider and convert that to a mapped value, but you won't be able to assign a value and set the slider position. In that sense it needs to be an invertible mapping. You might be able to solve that with Newton-Raphson or something, but it seems safest to just allow the user to specify the inverse mapping directly rather than guessing.
Closed in #12 actually
I've used it a couple of times, and it was really useful, being able to see the effect of a really high value when selecting the end of the slider.
It's the
scale: 'log'
option of the Slider, like it's implemented in control-panel.It would be awesome to have it in controls-state as well.