diff --git a/src/lib/components/cards/CardFan.svelte b/src/lib/components/cards/CardFan.svelte
new file mode 100644
index 0000000..4fe661f
--- /dev/null
+++ b/src/lib/components/cards/CardFan.svelte
@@ -0,0 +1,49 @@
+
+
+
+
+ {#each displayCards as card, i (i)}
+ {@const fanOffset = (totalCards - 1 - i) * 75}
+
+
+

+
+ {/each}
+
diff --git a/src/lib/components/cards/FrontBack.svelte b/src/lib/components/cards/FrontBack.svelte
index 1207668..54ff884 100644
--- a/src/lib/components/cards/FrontBack.svelte
+++ b/src/lib/components/cards/FrontBack.svelte
@@ -11,34 +11,22 @@
let fanned = $state(false);
const cardDeck: Attachment = (node) => {
- const observer = new IntersectionObserver(
- (entries) => {
- for (const entry of entries) {
- fanned = entry.isIntersecting;
- }
- },
- { rootMargin: "-40% 0px -40% 0px", threshold: 0 }
- );
-
- observer.observe(node);
-
- const onEnter = () => (fanned = true);
- const onLeave = () => (fanned = false);
-
- node.addEventListener("mouseenter", onEnter);
- node.addEventListener("mouseleave", onLeave);
-
- return () => {
- observer.disconnect();
- node.removeEventListener("mouseenter", onEnter);
- node.removeEventListener("mouseleave", onLeave);
+ const check = () => {
+ const rect = node.getBoundingClientRect();
+ const cardCenter = rect.top + rect.height / 2;
+ fanned = cardCenter <= window.innerHeight / 2;
};
+
+ window.addEventListener("scroll", check, { passive: true });
+ check();
+
+ return () => window.removeEventListener("scroll", check);
};
@@ -47,7 +35,7 @@
src={back}
alt="Back"
class="absolute inset-0 max-h-64 w-full object-contain drop-shadow-md transition-all duration-500 ease-in-out"
- style:transform={fanned ? "translateX(85px) rotate(5deg)" : "rotate(-2deg)"}
+ style:transform={fanned ? "translateX(90px) rotate(4deg)" : "rotate(-2deg)"}
style:z-index="1"
/>
@@ -55,7 +43,7 @@
src={front}
alt="Front"
class="absolute inset-0 max-h-64 w-full object-contain drop-shadow-md transition-all duration-500 ease-in-out"
- style:transform={fanned ? "translateX(-85px) rotate(-5deg)" : "rotate(2deg)"}
+ style:transform={fanned ? "translateX(-90px) rotate(-4deg)" : "rotate(2deg)"}
style:z-index="2"
/>
diff --git a/src/routes/cards/+page.svelte b/src/routes/cards/+page.svelte
index b8ce9d4..8d88c0f 100644
--- a/src/routes/cards/+page.svelte
+++ b/src/routes/cards/+page.svelte
@@ -1,22 +1,35 @@
BIBDLE Cards
-Collectible Bible Verse Trading Cards
-
+
Collectible Bible Verse Trading Cards
+
-
-
-
+
Card Fan Demo
+
Cards will fan out after a few seconds...
+
+
+
+
+
+