added alpine ajax - started conversion of the proj

This commit is contained in:
Simon Martens
2025-05-28 23:14:01 +02:00
parent fb8ac1b723
commit 168a733af1
24 changed files with 1412 additions and 1451 deletions

View File

@@ -0,0 +1,36 @@
export class ImageReel extends HTMLElement {
#minWidth = 176;
constructor() {
super();
this._images = [];
}
connectedCallback() {
this._images = Array.from(this.querySelectorAll(".primages"));
this.calculateShownImages();
const rObs = new ResizeObserver((__, _) => {
this.calculateShownImages();
});
this._resizeObserver = rObs;
rObs.observe(this);
}
disconnectedCallback() {
this._resizeObserver.unobserve(this);
}
calculateShownImages() {
const c = this.getBoundingClientRect();
console.log(c);
const fits = Math.floor(c.width / (this.#minWidth + 10));
for (let i = 0; i < this._images.length; i++) {
if (i < fits - 1) {
this._images[i].classList.remove("hidden");
} else {
this._images[i].classList.add("hidden");
}
}
}
}