+
+
diff --git a/site/views/items-filter.js b/site/views/items-filter.js
index 84cdede..768e567 100644
--- a/site/views/items-filter.js
+++ b/site/views/items-filter.js
@@ -24,7 +24,20 @@ class ItemsFilter extends View {
const placeholder = this.hasAttribute("placeholder") ? this.getAttribute("placeholder") : "Produkte suchen... (min. 3 Zeichen)";
this.innerHTML = /*html*/ `
+ ${
+ settings.stickySearch
+ ? `
+
+
+
+ `
+ : `
+ `
+ }
@@ -88,9 +101,21 @@ class ItemsFilter extends View {
)
.join("")}
+ ${
+ settings.stickySearch
+ ? `
+
+ `
+ : ""
+ }
`;
this.classList.add("items-filter");
+ if (settings.stickySearch) {
+ this.classList.add("sticky");
+ this.style = "top: -1px;z-index:20;";
+ }
+
const elements = this.elements;
elements.query.addEventListener("input", () => {
@@ -132,9 +157,11 @@ class ItemsFilter extends View {
});
this.setupEventHandlers();
+ this.setupStickyChart();
this.addEventListener("x-change", () => {
this.filter();
+ this.observe();
});
}
@@ -161,6 +188,35 @@ class ItemsFilter extends View {
}
}
+ setupStickyChart() {
+ if (!settings.stickySearch) return;
+ this.observer = new IntersectionObserver(
+ (entries) => {
+ for (const entry of entries) {
+ const clientRect = entry.target.getBoundingClientRect();
+ console.log(entry.target, entry.intersectionRatio);
+ if (entry.intersectionRatio < 0.999 && clientRect.top + clientRect.height < window.innerHeight) {
+ // Fix Edge issue
+ entry.target.classList.add("wrapper--pinned");
+ } else {
+ entry.target.classList.remove("wrapper--pinned");
+ }
+ }
+ },
+ {
+ rootMargin: "0px",
+ threshold: 0.999,
+ }
+ );
+ this.observe();
+ }
+
+ observe() {
+ if (this.observer == null) return;
+ this.observer.unobserve(this);
+ this.observer.observe(this);
+ }
+
filter() {
if (!this.model) return;
diff --git a/stores/hofer-categories.json b/stores/hofer-categories.json
index 4322b4c..efcfa9f 100644
--- a/stores/hofer-categories.json
+++ b/stores/hofer-categories.json
@@ -479,13 +479,13 @@
"code": "32"
},
{
- "id": "schweinefleisch-spezialitaten",
- "url": "https://www.roksh.at/hofer/angebot/schweinefleisch-spezialitaten",
+ "id": "faschiertes",
+ "url": "https://www.roksh.at/hofer/angebot/faschiertes",
"code": "32"
},
{
- "id": "faschiertes",
- "url": "https://www.roksh.at/hofer/angebot/faschiertes",
+ "id": "schweinefleisch-spezialitaten",
+ "url": "https://www.roksh.at/hofer/angebot/schweinefleisch-spezialitaten",
"code": "32"
},
{