From e9367ee85e443b28b003e3ff79ac0e2445879aa4 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Fri, 12 Apr 2019 20:18:17 +1000 Subject: Fix setting initial speed (fixes #1408) --- src/js/ui.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/js/ui.js') diff --git a/src/js/ui.js b/src/js/ui.js index 8e50bb83..50de7df1 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -67,15 +67,15 @@ const ui = { // Reset mute state this.muted = null; - // Reset speed - this.speed = null; - // Reset loop state this.loop = null; // Reset quality setting this.quality = null; + // Reset speed + this.speed = null; + // Reset volume display controls.updateVolume.call(this); @@ -233,13 +233,16 @@ const ui = { clearTimeout(this.timers.loading); // Timer to prevent flicker when seeking - this.timers.loading = setTimeout(() => { - // Update progress bar loading class state - toggleClass(this.elements.container, this.config.classNames.loading, this.loading); - - // Update controls visibility - ui.toggleControls.call(this); - }, this.loading ? 250 : 0); + this.timers.loading = setTimeout( + () => { + // Update progress bar loading class state + toggleClass(this.elements.container, this.config.classNames.loading, this.loading); + + // Update controls visibility + ui.toggleControls.call(this); + }, + this.loading ? 250 : 0, + ); }, // Toggle controls based on state and `force` argument @@ -248,10 +251,12 @@ const ui = { if (controls && this.config.hideControls) { // Don't hide controls if a touch-device user recently seeked. (Must be limited to touch devices, or it occasionally prevents desktop controls from hiding.) - const recentTouchSeek = (this.touch && this.lastSeekTime + 2000 > Date.now()); + const recentTouchSeek = this.touch && this.lastSeekTime + 2000 > Date.now(); // Show controls if force, loading, paused, button interaction, or recent seek, otherwise hide - this.toggleControls(Boolean(force || this.loading || this.paused || controls.pressed || controls.hover || recentTouchSeek)); + this.toggleControls( + Boolean(force || this.loading || this.paused || controls.pressed || controls.hover || recentTouchSeek), + ); } }, }; -- cgit v1.2.3 From c9055f391b3782d96d16fb6efa4337dc90120635 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sat, 1 Jun 2019 18:45:07 +1000 Subject: Linting changes --- src/js/ui.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/js/ui.js') diff --git a/src/js/ui.js b/src/js/ui.js index 50de7df1..df52eb64 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -213,7 +213,7 @@ const ui = { // Set state Array.from(this.elements.buttons.play || []).forEach(target => { - target.pressed = this.playing; + Object.assign(target, { pressed: this.playing }); }); // Only update controls on non timeupdate events @@ -247,15 +247,22 @@ const ui = { // Toggle controls based on state and `force` argument toggleControls(force) { - const { controls } = this.elements; + const { controls: controlsElement } = this.elements; - if (controls && this.config.hideControls) { + if (controlsElement && this.config.hideControls) { // Don't hide controls if a touch-device user recently seeked. (Must be limited to touch devices, or it occasionally prevents desktop controls from hiding.) const recentTouchSeek = this.touch && this.lastSeekTime + 2000 > Date.now(); // Show controls if force, loading, paused, button interaction, or recent seek, otherwise hide this.toggleControls( - Boolean(force || this.loading || this.paused || controls.pressed || controls.hover || recentTouchSeek), + Boolean( + force || + this.loading || + this.paused || + controlsElement.pressed || + controlsElement.hover || + recentTouchSeek, + ), ); } }, -- cgit v1.2.3