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`;