diff --git a/pages/onboard/first.js b/pages/onboard/first.js index fcdd8dc3..4086d604 100644 --- a/pages/onboard/first.js +++ b/pages/onboard/first.js @@ -228,8 +228,11 @@ const ShipPage = () => { const spotlightRef = useRef() useEffect(() => { const handler = event => { + const rect = spotlightRef.current.getBoundingClientRect() + const x = event.clientX - rect.left + const y = event.clientY - rect.top spotlightRef.current.style.background = `radial-gradient( - circle at ${event.pageX}px ${event.pageY}px, + circle at ${x}px ${y}px, rgba(0, 0, 0, 0) 10px, rgba(0, 0, 0, 0.8) 80px )` diff --git a/pages/onboard/index.js b/pages/onboard/index.js index e45dd1ec..e136f818 100644 --- a/pages/onboard/index.js +++ b/pages/onboard/index.js @@ -104,8 +104,11 @@ const ShipPage = () => { const spotlightRef = useRef() useEffect(() => { const handler = event => { + const rect = spotlightRef.current.getBoundingClientRect() + const x = event.clientX - rect.left + const y = event.clientY - rect.top spotlightRef.current.style.background = `radial-gradient( - circle at ${event.pageX}px ${event.pageY}px, + circle at ${x}px ${y}px, rgba(0, 0, 0, 0) 10px, rgba(0, 0, 0, 0.8) 80px )`