diff options
author | Albin Larsson <mail@albinlarsson.com> | 2018-05-16 04:52:04 +0200 |
---|---|---|
committer | Albin Larsson <mail@albinlarsson.com> | 2018-05-18 16:19:38 +0200 |
commit | 37c5fbfe16ba0969b727b8359fdd04eb0bf7a021 (patch) | |
tree | 2d0d236fb3af2e4c482e995efbb32994356b5d5d /src/js/ui.js | |
parent | d7356726a16d64d242cd20421bff431d66d146b8 (diff) | |
download | plyr-37c5fbfe16ba0969b727b8359fdd04eb0bf7a021.tar.lz plyr-37c5fbfe16ba0969b727b8359fdd04eb0bf7a021.tar.xz plyr-37c5fbfe16ba0969b727b8359fdd04eb0bf7a021.zip |
toggleControls() rewrite
Diffstat (limited to 'src/js/ui.js')
-rw-r--r-- | src/js/ui.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/js/ui.js b/src/js/ui.js index ea592d82..557599da 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -173,7 +173,7 @@ const ui = { } // Toggle controls - this.toggleControls(!this.playing); + ui.toggleControls.call(this); }, // Check if media is loading @@ -188,14 +188,24 @@ const ui = { // Timer to prevent flicker when seeking this.timers.loading = setTimeout(() => { - // Toggle container class hook + // Update progress bar loading class state utils.toggleClass(this.elements.container, this.config.classNames.loading, this.loading); - // Show controls if loading, hide if done - this.toggleControls(this.loading); + // Update controls visibility + ui.toggleControls.call(this); }, this.loading ? 250 : 0); }, + // Toggle controls based on state and `force` argument + toggleControls(force) { + const { controls } = this.elements; + + if (controls && this.config.hideControls) { + // Show controls if force, loading, paused, or button interaction, otherwise hide + this.toggleControls(Boolean(force || this.loading || this.paused || controls.pressed || controls.hover)); + } + }, + // Update volume UI and storage updateVolume() { if (!this.supported.ui) { |