1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-23 11:04:59 +02:00

fix(subs-caps-button): add hide threshold to subs-caps button (#4171)

This is a followup from #4157 but for the subs-caps button.
This commit is contained in:
Gary Katsevman 2017-03-07 13:52:51 -05:00 committed by GitHub
parent c611f9f358
commit 88ee6af431

View File

@ -40,33 +40,6 @@ class SubsCapsButton extends TextTrackButton {
return `vjs-subs-caps-button ${super.buildWrapperCSSClass()}`;
}
/**
* Update caption menu items
*
* @param {EventTarget~Event} [event]
* The `addtrack` or `removetrack` event that caused this function to be
* called.
*
* @listens TextTrackList#addtrack
* @listens TextTrackList#removetrack
*/
update(event) {
let threshold = 2;
super.update();
// if native, then threshold is 1 because no settings button
if (this.player().tech_ && this.player().tech_.featuresNativeTextTracks) {
threshold = 1;
}
if (this.items && this.items.length > threshold) {
this.show();
} else {
this.hide();
}
}
/**
* Create caption/subtitles menu items
*
@ -78,6 +51,8 @@ class SubsCapsButton extends TextTrackButton {
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.label_}));
this.hideThreshold_ += 1;
}
items = super.createItems(items, SubsCapsMenuItem);