drag range_slider to keep constant range
Description
With a range_slider with x_min and x_max defined, I would like to drag the middle of the range_slider and move that range such that x_max - x_min stays the same
Suggested solution
Provide a parameter to range_slider which allows this
Will you submit a PR?
- [x] Yes
Alternative
Not that I know of. Would have to do something custom
Additional context
No response
Thank you! This has been a feature desire for me too
Awesome. It would be helpful feature I cannot make a PR at the moment but would slowly get to it. Feel free to open something. I would tag draft once I would start
Hi! I'd like to work on this. My plan is to add a fixed_range: bool = False parameter to mo.ui.range_slider. When True, dragging between the handles moves both together keeping the range width constant. Does this API sound right before I start?
Hm, I'm not certain it needs another flag at all. If you click on the middle it'll move the full range, but clicking on the ends keeps the same behavior
Thanks for the quick response! I tried clicking the middle of the range slider but it doesn't seem to move both handles together, it just moves the nearest handle. Could you point me to where this behavior exists? I'm using the latest dev build.
I tried clicking the middle of the range slider but it doesn't seem to move both handles together, it just moves the nearest handle
Sorry, I was suggesting how the functionality could work with dragging the range- not what's active
Got it, thanks for clarifying! I'll go ahead and implement it with a fixed_range: bool = False parameter. I'll submit a PR once it's ready.
I think what Dylan mentioned is that we don't need a new param at all. It can be the default behaviour
Perfect, thanks @Light2Dark So the plan is: dragging the middle range bar moves both handles together as default behaviour, purely a frontend change in RangeSliderPlugin.tsx. I'll work on it and submit a PR!