From cf5f77c709b4ca1526e878fdc118fbedd593ef85 Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Fri, 15 Jun 2018 05:51:23 +0200 Subject: [PATCH] Fix menu transitionend event listener --- src/js/controls.js | 8 +++++--- src/js/plyr.js | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/js/controls.js b/src/js/controls.js index 0e28c222..f645e351 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -10,7 +10,7 @@ import { repaint, transitionEndEvent } from './utils/animation'; import { dedupe } from './utils/arrays'; import browser from './utils/browser'; import { createElement, emptyElement, getAttributesFromSelector, getElement, getElements, hasClass, removeElement, setAttributes, toggleClass, toggleHidden, toggleState } from './utils/elements'; -import { once } from './utils/events'; +import { on, off } from './utils/events'; import is from './utils/is'; import loadSprite from './utils/loadSprite'; import { extend } from './utils/objects'; @@ -1026,7 +1026,7 @@ const controls = { return; } - // Are we targetting a tab? If not, bail + // Are we targeting a tab? If not, bail const isTab = pane.getAttribute('role') === 'tabpanel'; if (!isTab) { return; @@ -1065,10 +1065,12 @@ const controls = { container.style.width = ''; container.style.height = ''; + // Only listen once + off.call(this, container, transitionEndEvent, restore); }; // Listen for the transition finishing and restore auto height/width - once.call(this, container, transitionEndEvent, restore); + on.call(this, container, transitionEndEvent, restore); // Set dimensions to target container.style.width = `${size.width}px`; diff --git a/src/js/plyr.js b/src/js/plyr.js index 4b9697ce..80555829 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -833,7 +833,7 @@ class Plyr { * @param {boolean} input - Whether to enable captions */ toggleCaptions(input) { - captions.toggle.call(this, input); + captions.toggle.call(this, input, false); } /** @@ -841,15 +841,15 @@ class Plyr { * @param {number} - Caption index */ set currentTrack(input) { - captions.set.call(this, input); + captions.set.call(this, input, false); } /** * Get the current caption track index (-1 if disabled) */ get currentTrack() { - const { active, currentTrack } = this.captions; - return active ? currentTrack : -1; + const { toggled, currentTrack } = this.captions; + return toggled ? currentTrack : -1; } /** @@ -858,7 +858,7 @@ class Plyr { * @param {string} - Two character ISO language code (e.g. EN, FR, PT, etc) */ set language(input) { - captions.setLanguage.call(this, input); + captions.setLanguage.call(this, input, false); } /**