diff options
author | Sam Potts <sam@potts.es> | 2018-06-15 15:33:39 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-15 15:33:39 +1000 |
commit | 3cd2b9a6c3ab2a7b530f1f0e6eae884ba41b9211 (patch) | |
tree | b09bd6de2ae5b234a8ff344c42da9ef313421a68 /src/js/plyr.js | |
parent | 019e1f80cad34cf40516cd9f039c5220717bf7d0 (diff) | |
parent | 19e412a73ac2e3e9f4c6ac9a086557a936109287 (diff) | |
download | plyr-3cd2b9a6c3ab2a7b530f1f0e6eae884ba41b9211.tar.lz plyr-3cd2b9a6c3ab2a7b530f1f0e6eae884ba41b9211.tar.xz plyr-3cd2b9a6c3ab2a7b530f1f0e6eae884ba41b9211.zip |
Merge pull request #1036 from friday/captions-passive-toggle
Captions fixes (again)
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 543291e7..80555829 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -19,7 +19,7 @@ import Storage from './storage'; import support from './support'; import ui from './ui'; import { closest } from './utils/arrays'; -import { createElement, hasClass, removeElement, replaceElement, toggleClass, toggleState, wrap } from './utils/elements'; +import { createElement, hasClass, removeElement, replaceElement, toggleClass, wrap } from './utils/elements'; import { off, on, once, triggerEvent, unbindListeners } from './utils/events'; import is from './utils/is'; import loadSprite from './utils/loadSprite'; @@ -833,25 +833,7 @@ class Plyr { * @param {boolean} input - Whether to enable captions */ toggleCaptions(input) { - // If there's no full support - if (!this.supported.ui) { - return; - } - - // If the method is called without parameter, toggle based on current value - const active = is.boolean(input) ? input : !this.elements.container.classList.contains(this.config.classNames.captions.active); - - // Toggle state - toggleState(this.elements.buttons.captions, active); - - // Add class hook - toggleClass(this.elements.container, this.config.classNames.captions.active, active); - - // Update state and trigger event - if (active !== this.captions.active) { - this.captions.active = active; - triggerEvent.call(this, this.media, this.captions.active ? 'captionsenabled' : 'captionsdisabled'); - } + captions.toggle.call(this, input, false); } /** @@ -859,15 +841,15 @@ class Plyr { * @param {number} - Caption index */ set currentTrack(input) { - captions.set.call(this, input); + captions.set.call(this, input, false); } /** * Get the current caption track index (-1 if disabled) */ get currentTrack() { - const { active, currentTrack } = this.captions; - return active ? currentTrack : -1; + const { toggled, currentTrack } = this.captions; + return toggled ? currentTrack : -1; } /** @@ -876,7 +858,7 @@ class Plyr { * @param {string} - Two character ISO language code (e.g. EN, FR, PT, etc) */ set language(input) { - captions.setLanguage.call(this, input); + captions.setLanguage.call(this, input, false); } /** |