-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
[Slider] Pass this.state.value into onDragStop & onDragStart #4712
Conversation
Someone I know was having issues getting the slider value back when the user stops sliding. It was being passed back whilst sliding (`onChange`) but that's now what they were after. From what I can see, the only way of getting that value is creating a ref on the Slider component and accessing `this.refs.slider.getValue()` within the `onDragStop` method. Like the `onChange` method, the second param is now the slider value. I also added the same to `onDragStart` for consistency.
@Ehesp I don't get it. What the issue with
Well, most component method should probably be considered internal. |
@Ehesp I'm gonna close this PR. We forward the |
I believe there is a valid use case where you cannot use onChange but you still need to access The You can't use This problem is clear if you want to use the slider for a media player. You want to keep the progress bar in sync with the music, and then update the music position when the What do you think? |
I also have a use case where I want stuff happening when the slider moves (e.g. changing grey scale in a canvas), while some DOM change should only happen on release, because otherwise the slider moves too fast for the action to complete (in this case, resizing a second slider). In other words, any event callback that takes more time to complete than for the slider to move by 1 tick cannot be triggered Having the value available I don't understand what the issue is to passing the value just like To complete the OP comment, a ref on the slider will not have the current slider value but only that of the previous tick. |
@karlfloersch I was thinking about exposing a callback property that is called when the slider position drag is over. We could call it
@jdelafon Sounds like an issue on userland. For this use cases, why not throttling the callback? Actually, I feel like you are having issues with handling the asynchronous aspect of the |
Because firstly, you want the onChange event to really fire on every tick, and secondly throttle will silence the observable for a duration, which means that you could (will most likely) miss the only tick that is meaningful for the onDragStop event: the last one. But I am not really familiar with this, and I am not saying there is not some way to do it somehow. I've always had the onMouseUp-like event I needed until now. Anyway, if you plan adding an |
@oliviertassinari Adding Just to verify, |
Yes indeed. I'm gonna submit a PR with the change. Would be awesome if you can have a look once it's done.
It looks like |
@oliviertassinari I'd be happy to review the PR! 😄 using |
I have noticed one use case that you might not be able to handle even with the new callback. |
doesn't seem like |
Someone I know was having issues getting the slider value back when the user stops sliding. It was being passed back whilst sliding (
onChange
) but that's now what they were after.From what I can see, the only way of getting that value is creating a ref on the Slider component and accessing
this.refs.slider.getValue()
within theonDragStop
method. Like theonChange
method, the second param is now the slider value. I also added the same toonDragStart
for consistency.