fix: breadcrumbs and marquee not observing clones

This commit is contained in:
Oleksandr 2026-03-16 10:59:00 +02:00
parent 0727eccb71
commit 2e505f7606
Signed by: Xanazf
GPG key ID: 821EEC32761AC17C
4 changed files with 23 additions and 19 deletions

View file

@ -192,13 +192,16 @@ document.addEventListener("DOMContentLoaded", () => {
});
}, observerOptions);
videos.forEach(v => {
videoObserver.observe(v);
v.addEventListener("ended", () => {
targetScrollX += itemWidth;
startAnimation();
const startObserving = () => {
const allVideos = scroller.querySelectorAll("video");
allVideos.forEach(v => {
videoObserver.observe(v);
v.addEventListener("ended", () => {
targetScrollX += itemWidth;
startAnimation();
});
});
});
};
// events
btnLeft?.addEventListener("click", () => {
@ -211,15 +214,15 @@ document.addEventListener("DOMContentLoaded", () => {
startAnimation();
});
container.addEventListener(
"wheel",
e => {
e.preventDefault();
targetScrollX += e.deltaY;
startAnimation();
},
{ passive: false }
);
// container.addEventListener(
// "wheel",
// e => {
// e.preventDefault();
// targetScrollX += e.deltaY;
// startAnimation();
// },
// { passive: false }
// );
container.addEventListener("touchstart", e => {
isDown = true;
@ -260,6 +263,7 @@ document.addEventListener("DOMContentLoaded", () => {
// init
setupClones();
startObserving();
setTimeout(() => {
updateDimensions();
container.classList.add("initialized");

View file

@ -21,8 +21,9 @@ let url = Astro.url.pathname.split("/").filter((s: string) => s !== "");
const breadcrumbs = [
{
text: "custom",
text: "Home",
href: "/",
slot: "index",
},
];
@ -69,7 +70,6 @@ for (const segment of url) {
data-pagefind-ignore
>
<svg
<!-- @ts-expect-error -->
slot="index"
xmlns="http://www.w3.org/2000/svg"
width="1em"
@ -83,7 +83,6 @@ for (const segment of url) {
></path>
</svg>
<svg
<!-- @ts-expect-error -->
slot="separator"
xmlns="http://www.w3.org/2000/svg"
width="1em"