adjusted drag function to fix panel/viewport overlap