diff options
Diffstat (limited to 'src/js/plugins')
-rw-r--r-- | src/js/plugins/previewThumbnails.js | 4 | ||||
-rw-r--r-- | src/js/plugins/youtube.js | 39 |
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); }); } }, |