79112511

Date: 2024-10-22 05:12:06
Score: 0.5
Natty:
Report link

After some gnashing of teeth I got it to work by changing the mousemove event's code to:

    const { offsetX, offsetY } = e,
          gw = glass.offsetWidth / 2,
          gh = glass.offsetHeight / 2;

    glass.style.left = `${offsetX - gw}px`;
    glass.style.top  = `${offsetY - gh}px`;

    const x = -Math.floor((offsetX / width)  * (width * zoom)  - gw),
          y = -Math.floor((offsetY / height) * (height * zoom) - gh);
    
    glass.style.backgroundPosition = `${x}px ${y}px`;
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Andrew Foulds