diff options
author | Sam Potts <sam@potts.es> | 2018-03-27 23:43:38 +1100 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-03-27 23:43:38 +1100 |
commit | 7b1e4abda7058c602c6d542ea2e12f0cba4fa332 (patch) | |
tree | ecc9c4c5b5a3468fe29d6ea054085ac4440d7b46 /src/js/plyr.js | |
parent | 0cf75eed3f8ec982300b2abdfd0347f638f83205 (diff) | |
download | plyr-7b1e4abda7058c602c6d542ea2e12f0cba4fa332.tar.lz plyr-7b1e4abda7058c602c6d542ea2e12f0cba4fa332.tar.xz plyr-7b1e4abda7058c602c6d542ea2e12f0cba4fa332.zip |
Controls fixes
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 061ac25c..2989146c 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -36,6 +36,9 @@ class Plyr { this.loading = false; this.failed = false; + // Touch device + this.touch = support.touch; + // Set the media element this.media = target; @@ -954,26 +957,32 @@ class Plyr { // Is the enter fullscreen event isEnterFullscreen = toggle.type === 'enterfullscreen'; - // Whether to show controls - show = [ - 'mouseenter', - 'mousemove', + // Events that show the controls + const showEvents = [ 'touchstart', 'touchmove', + 'mouseenter', + 'mousemove', 'focusin', - ].includes(toggle.type); + ]; - // Delay hiding on move events - if ([ - 'mousemove', + // Events that delay hiding + const delayEvents = [ 'touchmove', 'touchend', - ].includes(toggle.type)) { + 'mousemove', + ]; + + // Whether to show controls + show = showEvents.includes(toggle.type); + + // Delay hiding on move events + if (delayEvents.includes(toggle.type)) { delay = 2000; } // Delay a little more for keyboard users - if (toggle.type === 'focusin') { + if (!this.touch && toggle.type === 'focusin') { delay = 3000; utils.toggleClass(this.elements.controls, this.config.classNames.noTransition, true); } @@ -1001,7 +1010,7 @@ class Plyr { } // Delay for hiding on touch - if (support.touch) { + if (this.touch) { delay = 3000; } } @@ -1010,6 +1019,8 @@ class Plyr { // then set the timer to hide the controls if (!show || this.playing) { this.timers.controls = setTimeout(() => { + console.warn(this.elements.controls.pressed, this.elements.controls.hover, delay); + // If the mouse is over the controls (and not entering fullscreen), bail if ((this.elements.controls.pressed || this.elements.controls.hover) && !isEnterFullscreen) { return; |