-
Notifications
You must be signed in to change notification settings - Fork 946
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
Add dragging behaviour properties to sliders #2834
Conversation
#2832, right? I was thinking it might be better to start out with just changing the default behavior to Thoughts? I know I've become very conservative about extending the core ipywidgets api because it aims to be very stable over a long term, so I'm wary of adding maintenance burdens. |
If exposing this behavior to the users is the way we want to go, then I think you've done a great job here (just reading the code, I haven't run it yet) |
Indeed. Updated the PR note above with the correct one, thanks for spotting!
Potentially yes. Off the top of my head, let's say I'm using the range slider to control the spot range of a vanilla option payoff at expiry. I would probably not want to drag both handles of the slider at the same time given I am only looking to focus on the strike area. But then again, it might be convenient to drag the full range if I got the original parameters wrong and need to shift my window left or right.
I'm definitely with you on robustness. I added the snap behaviour because I often expected the slider handles to behave that way and thought other users might also appreciate that option. If you think we are incurring potential technical debt down the line then I'm happy to remove the changes! |
We could also consider to "expose" it as an underscore param |
@jasongrout How should we proceed? |
For folks wanting to try this PR on Binder: https://mybinder.org/v2/gh/ibdafna/ipywidgets/drag_behaviour?urlpath=lab/tree/docs/source/examples/ |
ipywidgets/widgets/widget_float.py
Outdated
@@ -159,6 +159,8 @@ class FloatSlider(_BoundedFloat): | |||
default is 'horizontal', orientation of the slider | |||
readout : {True, False} | |||
default is True, display the current value of the slider next to it | |||
behaviour : str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting here as this came up during the weekly meeting today, with @ianhi spotting this attribute was not in American English:
behaviour : str | |
behavior : str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that was probably because of noUISlider
using behaviour
in the options:
https://refreshless.com/nouislider/slider-options/#section-limit
040def6
to
3aae838
Compare
FYI @ibdafna I rebased and added a commit to rename |
@jtpio thank you 😄 |
This PR adds functionality requested in #2832 . The drag behaviour API has been exposed on the python side and now allows four selections:
There are no breaking API changes, but a new
behaviour
attribute has been added to the python side.