mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 17:25:32 +00:00
28 lines
609 B
JavaScript
28 lines
609 B
JavaScript
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}`);
|
|
}
|
|
}
|
|
}
|
|
}
|