From 62f7e6ce68800d6961660b3944774ff7bfb77226 Mon Sep 17 00:00:00 2001
From: William Warriner <6930772+wwarriner@users.noreply.github.com>
Date: Mon, 7 Oct 2024 16:23:38 -0500
Subject: [PATCH] add rstackfix plugin

---
 rStackFix/plugin.js  | 34 ++++++++++++++++++++++++++++++++++
 rStackFix/plugin.yml |  2 ++
 2 files changed, 36 insertions(+)
 create mode 100644 rStackFix/plugin.js
 create mode 100644 rStackFix/plugin.yml

diff --git a/rStackFix/plugin.js b/rStackFix/plugin.js
new file mode 100644
index 0000000..386de58
--- /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 0000000..2d1cf40
--- /dev/null
+++ b/rStackFix/plugin.yml
@@ -0,0 +1,2 @@
+name: rStackFix
+script: [plugin.js]
-- 
GitLab