probably Try this ,
I am not sure but it should work, just change the last line
i.e, transform.position = pos; to transform.position = Camera.main.ViewportToWorldPoint(pos);