The grey ball can be dragged around.
The eye sprite is only visible when a clear path with no obstacles is possible to the grey ball.
The eye becomes invisible when obstacles are in the way between the eye and grey ball.
You can check the code to see how it’s done.
(This runs well on a tablet and glitches when played on a pc browser)