Skip to content
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

Feature Request: Play/Pause Button #74

Open
alexandergerber opened this issue Nov 13, 2019 · 11 comments
Open

Feature Request: Play/Pause Button #74

alexandergerber opened this issue Nov 13, 2019 · 11 comments

Comments

@alexandergerber
Copy link

I would really like to have an optional play/pause button for the sliders.
Would that be within the scope of your project?

@johnwalley
Copy link
Owner

I'd say it's outside the scope of the project. I see it being made up of two parts:

  1. ui controls for play/pause
  2. functionality to repeatedly update the value of the slider when it is in the 'play' state

That said, I think it would make a good example/demo. I've got no immediate plans to add any new examples but I will update this issue if I do get around to it.

If you wanted to have a go yourself, perhaps as a codepen, I'd be happy to provide assistance.

@geohuz
Copy link

geohuz commented Oct 30, 2020

I'm wondering except for setting value (slider.value(x)) to make the slider changes, is there any api to tell the slider step into next point according to the setup? (Eg, we have set min, max, and step, now we just call sth to make it forward or backward?) We need API interacts with programmatic controls the slider.

@johnwalley
Copy link
Owner

Hi @geohuz and thanks for the question. You are right in saying that the only way to currently do this is to set the slider value explicitly. I don't have any current plans to add a method to to step to the next (or previous point).

However, I'll finally get around to putting together an example of doing this in the next week or so.

@johnwalley
Copy link
Owner

johnwalley commented Nov 11, 2020

I've started work on an example in this PR #127

Nov-11-2020 20-29-56

@geohuz
Copy link

geohuz commented Feb 9, 2021

This is awesome! Can we use it for now?

@johnwalley
Copy link
Owner

Yes, feel free to use the code. I'll also merge the PR this weekend.

@geohuz
Copy link

geohuz commented Mar 12, 2021

hi @johnwalley would you give me a link for the example code? I could't find it any where, thanks

@johnwalley
Copy link
Owner

https://github.com/johnwalley/d3-simple-slider/pull/168/files

Still in the PR for now :)

@geohuz
Copy link

geohuz commented Mar 17, 2021

Hi @johnwalley thanks for the demo, I've tried to wrap the player into react component, but I found the marker don't move, only the fill progress. Would you mind help me to fix the issue? Here is the link on code sandbox: https://codesandbox.io/s/optimistic-brook-l09pp?file=/src/App.js

Thanks

@johnwalley
Copy link
Owner

You could do something like this: https://codesandbox.io/s/angry-river-gldvt.

They key is to avoid getting into an infinite loop (user moves handle -> call setPosition -> set value on slider -> call setPosition ->...) which is where slientValue helps.

@geohuz
Copy link

geohuz commented Mar 17, 2021

@johnwalley appreciate it so much! problem solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants