alexanderwallin / react-player-controls

⏯ Dumb and (re)useful React components for media players.
http://alexanderwallin.github.io/react-player-controls/
ISC License
191 stars 35 forks source link

Adds onIntentStart and onIntentEnd props to <Slider /> #48

Closed alexanderwallin closed 5 years ago

alexanderwallin commented 5 years ago

Using the new onIntentStart and onIntentEnd callback props on the <Slider />, one can now be noticed of when the user enters and leaves the slider element with the mouse while not dragging.

alexanderwallin commented 5 years ago

One thing I struggled with here is the relationship between intent and dragging/changing. I went with the rule that intent events are only triggered when the user is not dragging, since when they're actually changing the value, "intent" is not applicable.

However, this introduces a little more verbosity on the user-side, since you cannot rely on onIntentEnd being invoked every time the user leaves the slider with the mouse – f.i., it will not be invoked when leaving it while dragging the handle.

One alternative would be to call onIntentEnd when dragging or changing occurs. This would make sense linguistically, but is it what you would expect as a developer?

rijk commented 5 years ago

Some background on how I plan to use this: I have a time display next to the progress bar, which shows [current] / [duration]. While displaying intent, this would change to [intent] / [duration]. When you move the mouse out, it should revert back to [current] / [duration] (which it currently does not).

Another use case is showing a time tooltip whenever the user is hovering over the progress bar.

In both cases, ending the intent when the user starts dragging would make sense from a developer perspective. This would either hide the tooltip, or change the time display back to [current] / [duration], where [current] will show the position of the handle.

What happens right now when you go from intent (hovering) to changing (dragging)? Is onIntentEnd called when you start dragging? If you ask me, I think that would be the right path to implement this.

alexanderwallin commented 5 years ago

Thanks for the background intel, and I guess those are the typical kind of features you would use intents for. Let's end intents when dragging starts!

rijk commented 5 years ago

Yeah, that would make sense. As soon as you click, regardless of if it's a click or drag, it is no longer an intent but something you actually do/are doing.

alexanderwallin commented 5 years ago

Exactly!

alexanderwallin commented 5 years ago

1.1.0 is now released. Go build awesome hover stuff!