From 7a776eeeea5d0716210cbb60ef95ebe0437bddd7 Mon Sep 17 00:00:00 2001 From: Chuong Date: Sat, 18 Nov 2017 03:09:45 +0700 Subject: [PATCH] fix: being able to toggle playback with middle click (#4756) Uses the new Dom.isSingleLeftClick method to do the check we were doing previously. Also, refactor the player.handleTechClick_() method to follow the new style of code. Fixes #4689 --- src/js/player.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/js/player.js b/src/js/player.js index 5a80f1b2dc..95bf70e8ed 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -1430,20 +1430,20 @@ class Player extends Component { * @private */ handleTechClick_(event) { - // We're using mousedown to detect clicks thanks to Flash, but mousedown - // will also be triggered with right-clicks, so we need to prevent that - if (event.button !== 0) { + if (!Dom.isSingleLeftClick(event)) { return; } // When controls are disabled a click should not toggle playback because // the click is considered a control - if (this.controls()) { - if (this.paused()) { - this.play(); - } else { - this.pause(); - } + if (!this.controls_) { + return; + } + + if (this.paused()) { + this.play(); + } else { + this.pause(); } }