I'd say that all of this belongs inside of mouseDrag, in the same spot where top and left are modified.