Refactor drag and resize
Apply the rotation fix after refactoring