Skip to content

Commit

Permalink
refactor: player.usingNativeControls() (#4749)
Browse files Browse the repository at this point in the history
  • Loading branch information
kocoten1992 authored and gkatsev committed Nov 16, 2017
1 parent 79b4355 commit eb909f0
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2711,37 +2711,40 @@ class Player extends Component {
* The current value of native controls when getting
*/
usingNativeControls(bool) {
if (bool !== undefined) {
bool = !!bool;

// Don't trigger a change event unless it actually changed
if (this.usingNativeControls_ !== bool) {
this.usingNativeControls_ = bool;
if (bool) {
this.addClass('vjs-using-native-controls');
if (bool === undefined) {
return !!this.usingNativeControls_;
}

/**
* player is using the native device controls
*
* @event Player#usingnativecontrols
* @type {EventTarget~Event}
*/
this.trigger('usingnativecontrols');
} else {
this.removeClass('vjs-using-native-controls');
bool = !!bool;

/**
* player is using the custom HTML controls
*
* @event Player#usingcustomcontrols
* @type {EventTarget~Event}
*/
this.trigger('usingcustomcontrols');
}
}
// Don't trigger a change event unless it actually changed
if (this.usingNativeControls_ === bool) {
return;
}
return !!this.usingNativeControls_;

this.usingNativeControls_ = bool;

if (this.usingNativeControls_) {
this.addClass('vjs-using-native-controls');

/**
* player is using the native device controls
*
* @event Player#usingnativecontrols
* @type {EventTarget~Event}
*/
this.trigger('usingnativecontrols');
} else {
this.removeClass('vjs-using-native-controls');

/**
* player is using the custom HTML controls
*
* @event Player#usingcustomcontrols
* @type {EventTarget~Event}
*/
this.trigger('usingcustomcontrols');
}
}

/**
Expand Down

0 comments on commit eb909f0

Please sign in to comment.