File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ var Mute = React.createClass({
33
33
* @return {undefined }
34
34
*/
35
35
changeVolume ( e ) {
36
- this . props . setVolume ( e . target . value / 100 ) ;
36
+ this . props . setVolume ( e . target . value / 100 , true ) ;
37
37
this . props . unmute ( ) ;
38
38
} ,
39
39
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ var Seek = React.createClass({
40
40
* @return {undefined }
41
41
*/
42
42
seek ( e ) {
43
- this . props . seek ( e . target . value * this . props . duration / 100 ) ;
43
+ this . props . seek ( e . target . value * this . props . duration / 100 , true ) ;
44
44
} ,
45
45
46
46
onFocus ( ) {
Original file line number Diff line number Diff line change @@ -196,19 +196,37 @@ var Video = React.createClass({
196
196
/**
197
197
* Seeks the video timeline.
198
198
* @param {number } time The value in seconds to seek to
199
+ * @param {bool } forceUpdate Forces a state update without waiting for
200
+ * throttled event.
199
201
* @return {undefined }
200
202
*/
201
- seek ( time ) {
203
+ seek ( time , forceUpdate ) {
202
204
this . videoEl . currentTime = time ;
205
+ // In some use cases, we wish not to wait for `onSeeked` or `onSeeking`
206
+ // throttled event to update state so we force it. This is because
207
+ // this method is often triggered when dragging a bar and can feel janky.
208
+ // See https://github.com/mderrick/react-html5video/issues/43
209
+ if ( forceUpdate ) {
210
+ this . updateStateFromVideo ( ) ;
211
+ }
203
212
} ,
204
213
205
214
/**
206
215
* Sets the video volume.
207
216
* @param {number } volume The volume level between 0 and 1.
217
+ * @param {bool } forceUpdate Forces a state update without waiting for
218
+ * throttled event.
208
219
* @return {undefined }
209
220
*/
210
- setVolume ( volume ) {
221
+ setVolume ( volume , forceUpdate ) {
211
222
this . videoEl . volume = volume ;
223
+ // In some use cases, we wish not to wait for `onVolumeChange`
224
+ // throttled event to update state so we force it. This is because
225
+ // this method is often triggered when dragging a bar and can feel janky.
226
+ // See https://github.com/mderrick/react-html5video/issues/43
227
+ if ( forceUpdate ) {
228
+ this . updateStateFromVideo ( ) ;
229
+ }
212
230
} ,
213
231
214
232
/**
You can’t perform that action at this time.
0 commit comments