Issue of snaping object

Hi,

Please help to make snap object on the mouse movement.

As, I have made the code but getting issue on removing from snapping.

I have attached the file.

Thanks in advance…