Skip to content

Commit

Permalink
theme(fix): add static function to webcomponents
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Kollitsch <patrick@davids-neighbour.com>
  • Loading branch information
davidsneighbour committed Jan 14, 2025
1 parent d2e4113 commit 4b6b6da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions assets/js/components/click-effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ClickSpark extends HTMLElement {
this.svg.style.top = "0px";

this.root.addEventListener("click", (e) => {
if (!e.target.closest('a')) return;
if (!e.target.closest("a")) return;

this.setSparkPosition(e);
this.animateSpark();
Expand Down Expand Up @@ -56,8 +56,10 @@ class ClickSpark extends HTMLElement {
setSparkPosition(e) {
let rect = this.root.getBoundingClientRect();

this.svg.style.left = e.clientX - rect.left - this.svg.clientWidth / 2 + "px";
this.svg.style.top = e.clientY - rect.top - this.svg.clientHeight / 2 + "px";
this.svg.style.left =
e.clientX - rect.left - this.svg.clientWidth / 2 + "px";
this.svg.style.top =
e.clientY - rect.top - this.svg.clientHeight / 2 + "px";
}

setupSpark() {
Expand Down Expand Up @@ -88,6 +90,10 @@ class ClickSpark extends HTMLElement {
this.shadowRoot.innerHTML = template;
this.svg = this.shadowRoot.querySelector("svg");
}

static {
console.log("Spark loaded");
}
}

export default ClickSpark;
3 changes: 3 additions & 0 deletions assets/js/components/progress-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class ProgressBar extends HTMLElement {
</div>
`;
}
static {
console.log('ProgressBar loaded');
}
}

export default ProgressBar;

0 comments on commit 4b6b6da

Please sign in to comment.