Skip to content

Commit

Permalink
fix: use click event for tech click event
Browse files Browse the repository at this point in the history
Flash is not really a thing anymore.
Prevent some weird behaviour when pressing left click outside the player, move the custor inside the player and release the button
  • Loading branch information
Chocobozzz committed Jul 2, 2021
1 parent a8a5e02 commit 632187b
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1317,12 +1317,7 @@ class Player extends Component {
// Make sure to remove all the previous listeners in case we are called multiple times.
this.removeTechControlsListeners_();

// Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
// trigger mousedown/up.
// http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
// TODO: Is this needed for any techs other than Flash?
// Any touch events are set to block the mousedown event from happening
this.on(this.tech_, 'mouseup', this.boundHandleTechClick_);
this.on(this.tech_, 'click', this.boundHandleTechClick_);
this.on(this.tech_, 'dblclick', this.boundHandleTechDoubleClick_);

// If the controls were hidden we don't want that to change without a tap event
Expand Down Expand Up @@ -1350,7 +1345,7 @@ class Player extends Component {
this.off(this.tech_, 'touchstart', this.boundHandleTechTouchStart_);
this.off(this.tech_, 'touchmove', this.boundHandleTechTouchMove_);
this.off(this.tech_, 'touchend', this.boundHandleTechTouchEnd_);
this.off(this.tech_, 'mouseup', this.boundHandleTechClick_);
this.off(this.tech_, 'click', this.boundHandleTechClick_);
this.off(this.tech_, 'dblclick', this.boundHandleTechDoubleClick_);
}

Expand Down Expand Up @@ -1926,14 +1921,10 @@ class Player extends Component {
* @param {EventTarget~Event} event
* the event that caused this function to trigger
*
* @listens Tech#mouseup
* @listens Tech#click
* @private
*/
handleTechClick_(event) {
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_) {
Expand Down

0 comments on commit 632187b

Please sign in to comment.