aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plugins
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2019-06-01 19:50:29 +1000
committerSam Potts <sam@potts.es>2019-06-01 19:50:29 +1000
commit0249772f019762ebd494ac409e597103820413c3 (patch)
tree9831cbec7cf13676dba464cc01679fab2172f103 /src/js/plugins
parent5d699d5f47e5bce9e6c59ff5a1f3fab236d7e00f (diff)
downloadplyr-0249772f019762ebd494ac409e597103820413c3.tar.lz
plyr-0249772f019762ebd494ac409e597103820413c3.tar.xz
plyr-0249772f019762ebd494ac409e597103820413c3.zip
Clean up
Diffstat (limited to 'src/js/plugins')
-rw-r--r--src/js/plugins/previewThumbnails.js4
-rw-r--r--src/js/plugins/youtube.js39
2 files changed, 17 insertions, 26 deletions
diff --git a/src/js/plugins/previewThumbnails.js b/src/js/plugins/previewThumbnails.js
index f3359a4f..b4714117 100644
--- a/src/js/plugins/previewThumbnails.js
+++ b/src/js/plugins/previewThumbnails.js
@@ -426,7 +426,9 @@ class PreviewThumbnails {
if (image.dataset.index !== currentImage.dataset.index && !image.dataset.deleting) {
// Wait 200ms, as the new image can take some time to show on certain browsers (even though it was downloaded before showing). This will prevent flicker, and show some generosity towards slower clients
// First set attribute 'deleting' to prevent multi-handling of this on repeat firing of this function
- extend(image, { dataset: { deleting: true } });
+ // eslint-disable-next-line no-param-reassign
+ image.dataset.deleting = true;
+
// This has to be set before the timeout - to prevent issues switching between hover and scrub
const { currentImageContainer } = this;
diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js
index bf933646..34c5de7e 100644
--- a/src/js/plugins/youtube.js
+++ b/src/js/plugins/youtube.js
@@ -47,8 +47,6 @@ function getHost(config) {
return undefined;
}
-let onYouTubeReadyCallbacks;
-
const youtube = {
setup() {
// Add embed class for responsive
@@ -58,31 +56,22 @@ const youtube = {
if (is.object(window.YT) && is.function(window.YT.Player)) {
youtube.ready.call(this);
} else {
+ // Reference current global callback
+ const callback = window.onYouTubeIframeAPIReady;
+
+ // Set callback to process queue
+ window.onYouTubeIframeAPIReady = () => {
+ // Call global callback if set
+ if (is.function(callback)) {
+ callback();
+ }
- if (!onYouTubeReadyCallbacks) {
- const oldYouTubeIframeAPIReady = window.onYouTubeIframeAPIReady;
- // Load the API
- onYouTubeReadyCallbacks = [];
-
- // Set callback to process queue
- window.onYouTubeIframeAPIReady = () => {
- if (oldYouTubeIframeAPIReady && is.function(oldYouTubeIframeAPIReady)) {
- oldYouTubeIframeAPIReady();
- }
-
- window.onYouTubeReadyCallbacks.forEach(callback => {
- callback();
- });
- };
-
- loadScript(this.config.urls.youtube.sdk).catch(error => {
- this.debug.warn('YouTube API failed to load', error);
- });
- }
-
- // Add to queue
- onYouTubeReadyCallbacks.push(() => {
youtube.ready.call(this);
+ };
+
+ // Load the SDK
+ loadScript(this.config.urls.youtube.sdk).catch(error => {
+ this.debug.warn('YouTube API failed to load', error);
});
}
},