mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 17:25:32 +00:00
added alpine ajax - started conversion of the proj
This commit is contained in:
27
views/transform/int-link.js
Normal file
27
views/transform/int-link.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export class IntLink extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
// Basic styling to mimic a link.
|
||||
this.style.cursor = "pointer";
|
||||
this.addEventListener("click", this.handleClick);
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
this.removeEventListener("click", this.handleClick);
|
||||
}
|
||||
|
||||
handleClick(event) {
|
||||
const selector = this.getAttribute("data-jump");
|
||||
if (selector) {
|
||||
const target = document.querySelector(selector);
|
||||
if (target) {
|
||||
target.scrollIntoView({ behavior: "smooth" });
|
||||
} else {
|
||||
console.warn(`No element found for selector: ${selector}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user