15 lines
496 B
JavaScript
15 lines
496 B
JavaScript
{489d71df70e3233b91e874658c5198853be5d408 true 496 script.js 0xc001e6f9d0}
const container = document.getElementById("container");
|
|
const img = document.querySelector("img");
|
|
|
|
container.addEventListener("mousemove", (e) => {
|
|
const x = e.clientX - e.target.offsetLeft;
|
|
const y = e.clientY - e.target.offsetTop;
|
|
console.log(x, y);
|
|
|
|
img.style.transformOrigin = `${x}px ${y}px`;
|
|
img.style.transform = "scale(2)";
|
|
});
|
|
container.addEventListener("mouseleave", () => {
|
|
img.style.transformOrigin = "center center";
|
|
img.style.transform = "scale(1)";
|
|
}); |