- {timeline.map((entry, index) => (
-
-
- {entry.event}
-
-
- {entry.eventDetail}
-
-
- {entry.description && (
-
- {entry.description}
-
- )}
-
- ))}
+
+
+ {timeline.map((entry, index) => (
+
+
+ {entry.event}
+
+
+ {entry.eventDetail}
+
+
+ {entry.description && (
+
+ {entry.description}
+
+ )}
+
+ ))}
+
+
diff --git a/src/components/Timeline/timeline.ts b/src/components/Timeline/timeline.ts
index 57095c9..ec3c272 100644
--- a/src/components/Timeline/timeline.ts
+++ b/src/components/Timeline/timeline.ts
@@ -25,21 +25,47 @@ class CustomTimeline extends HTMLElement {
}
}).filter(pair => pair !== undefined)
- let contentBodyScrolling = document.getElementById("content-body-scrolling")
+ let contentBodyScrolling = document.getElementById("content-body-scrolling");
+ let wrapper = this.querySelector("[data-custom-timeline-line-wrapper]") as HTMLElement;
+
+ const position = (line: LeaderLine) => {
+ wrapper.style.transform = "none";
+ let rectWrapper = wrapper.getBoundingClientRect();
+
+ wrapper.style.transform = "translate(-" +
+ (Number(rectWrapper.left)) + "px, -"
+ +
+ (Number(rectWrapper.top)) + "px)"
+
+ console.log(wrapper.style.transform)
+ line.position()
+
+ }
pairs.forEach(pair => {
let line = new LeaderLine({
- start: pair[0],
- end: pair[1],
- color: '#10ac25',
- size: 3,
- startSocket: "right",
- endSocket: "left",
- startPlug: "square",
- endPlug: "arrow3"
- });
- contentBodyScrolling?.addEventListener("scroll", () => line.position())
+ start: pair[0],
+ end: pair[1],
+ color: '#10ac25',
+ size: 3,
+ startSocket: "right",
+ endSocket: "left",
+ startPlug: "square",
+ endPlug: "arrow3"
+ });
+
+ // Find new element by hidden id and add to wrapper div
+ const newLineEl = document.querySelector(`body .leader-line:has(path#leader-line-${line._id}-line-path)`);
+ if (newLineEl) wrapper.appendChild(newLineEl);
+
+ // Add position updaters for scrolling and resize events
+ contentBodyScrolling?.addEventListener("scroll", () => position(line));
+ window.addEventListener("resize", () => position(line));
+
+ // Perform the initial positioning
+ position(line);
});
+
}
}
diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro
index b2187e9..d4b1dad 100644
--- a/src/layouts/BaseLayout.astro
+++ b/src/layouts/BaseLayout.astro
@@ -28,8 +28,8 @@ const pageEnabled = pathToMetadata(Astro.url.pathname).enabled ?? true;
{pageEnabled ? pageTitle : "Corwin Perren"}
-
-