Implementing functions for drag/resize. Not tested.