Dragging mouse cursor to resize a rectangle object

Hello. I have a 2-D rectangle which I have rendered to the webgl window . I would like the user to use the mouse cursor to resize the length / width of the rectangle such that when one the mouse cursor clicks on one side, the edge is highlighted red. I have achieved upto this point but now I would like the adjacent edges to move in the direction of the mouse cursor.

I have attached an image to show what I want. Any suggestions on how to go about this? . Please note that the edge being dragged should move at the same speed as the mouse cursor and thus there should be no relative movement between the cursor and the edge. As of now I have some relative movement and am not able to solve this issue. Thanks!

Sorry about the bad image. I could not screen shot to show the cursor as well so I took the image from my phone!