How to make a drag and drop snap like in 1010

I want to be able to make a game where you drag and drop things based on a grid, like the 1010 mobile game.

1010 game images.
https://www.google.com/search?q=1010&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiJ6-nnt83LAhWFND4KHW8CDKIQ_AUICSgD&biw=1366&bih=635