Skip to content

Add slider events #1126

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

Merged
merged 6 commits into from
Nov 9, 2016
Merged

Add slider events #1126

merged 6 commits into from
Nov 9, 2016

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Nov 9, 2016

Due to a lack of events, sliders that execute custom code in pure JS are very difficult. This PR adds events to sliders:

  • plotly_sliderstart: emitted when the slider receives a mousedown event
  • plotly_sliderchange: emitted when the slider receives interaction that changes the selected value. Data contains interaction: true | false in order to indicate whether the change was the result of user interaction of some other state change like bindings.
  • plotly_sliderend: emitted on mouseup

@etpinard
Copy link
Contributor

etpinard commented Nov 9, 2016

@rreusser can you give a real world example of these events in action?

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

change would be useful for hooking into a play button. Like performing external updates as an animation progresses. It's more of a notification that the slider moved.

dragmove is similar except restricts this to only events that were the result of direct input to the component, like for actually performing changes that don't fit into an API command (like computing live data and updating the plot). Perhaps this could get merged with change with the addition of a flag that denotes whether it was direct input or not.

dragstart and dragend are two that I use frequently to do something like pausing a simulation or lowering the resolution while the component is being interacted with.

here is an example where the simulation pauses during interaction.

here is an example that would greatly benefit from the ability to lower resolution while the component is being dragged for a quick preview.

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

@etpinard what do you think of sliderstart, sliderend, and sliderchange, where sliderchange has an interaction: true | false flag that notes whether it was the result of interaction or just a more general state change (e.g. bindings)?

@etpinard
Copy link
Contributor

etpinard commented Nov 9, 2016

what do you think of sliderstart, sliderend, and sliderchange, where sliderchange has an interaction: true | false flag that notes whether it was the result of interaction or just a more general state change (e.g. bindings)?

love it 👍

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

This PR has been updated as discussed. The initial description now specifies the three events implemented.

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

@etpinard the individual commits are a little messy since I accidentally committed the linter changes, but the end result is correct (pending circle-ci).

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

For live example, see console output at: http://rickyreusser.com/animation-experiments/#gapminder

@etpinard
Copy link
Contributor

etpinard commented Nov 9, 2016

nicely done 💃

@etpinard etpinard added this to the v1.20.0 milestone Nov 9, 2016
@rreusser rreusser merged commit 653fe76 into master Nov 9, 2016
@rreusser rreusser deleted the slider-events branch November 9, 2016 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants