diff --git a/rStackFix/plugin.js b/rStackFix/plugin.js new file mode 100644 index 0000000000000000000000000000000000000000..386de58de9f5bb779abcaf16b7ade0984b9da991 --- /dev/null +++ b/rStackFix/plugin.js @@ -0,0 +1,34 @@ +window.rStackFix = function () { + return { + id: "rStackFix", + init: function (deck) { + console.log("Custom plugin initialized!"); + // Automatically load the initial fragment on a slide if the fragment + // has been defined with the 'preload' class + deck.on("slidechanged", function (event) { + console.log("slidechanged"); + if ( + event.currentSlide.querySelectorAll( + '.preload[data-fragment-index="0"]' + ).length > 0 + ) { + deck.nextFragment(); + } + }); + + // If the initial fragment on a slide has been defined with a 'preload' class + // then transition to the previous slide if the fragment is hidden + deck.on("fragmenthidden", function (event) { + console.log("fragmenthidden"); + if ( + event.fragment.hasAttribute("data-fragment-index") && + event.fragment.classList.contains("preload") + ) { + if (event.fragment.attributes["data-fragment-index"].value == "0") { + deck.prev(); + } + } + }); + }, + }; +}; diff --git a/rStackFix/plugin.yml b/rStackFix/plugin.yml new file mode 100644 index 0000000000000000000000000000000000000000..2d1cf405fd0dae1309559b3b8152e2d1d9c7ceff --- /dev/null +++ b/rStackFix/plugin.yml @@ -0,0 +1,2 @@ +name: rStackFix +script: [plugin.js]