Oops, fix magnifier position bug when page is scrolled

This commit is contained in:
Emi Matchu 2024-12-07 12:41:03 -08:00
parent 347419aee8
commit 30d42d29c1

View file

@ -14,8 +14,8 @@ class MagicMagnifier extends HTMLElement {
#onMouseMove(e) { #onMouseMove(e) {
const lens = this.querySelector("magic-magnifier-lens"); const lens = this.querySelector("magic-magnifier-lens");
const rect = this.getBoundingClientRect(); const rect = this.getBoundingClientRect();
const x = e.pageX - rect.left; const x = e.clientX - rect.left;
const y = e.pageY - rect.top; const y = e.clientY - rect.top;
this.style.setProperty("--magic-magnifier-x", x + "px"); this.style.setProperty("--magic-magnifier-x", x + "px");
this.style.setProperty("--magic-magnifier-y", y + "px"); this.style.setProperty("--magic-magnifier-y", y + "px");
} }