Don't keep on testing for collisions or congruency (overlapping) WHILE you're dragging... you've already detected that the mouse cursor was over the rectangle when you clicked the button.
Just set the rectangle's origin point equal to the mouseX and mouseY every loop, and the rectangle will ALWAYS be drawn at the mouse pointer. The rectangle will essentially move at the same speed as you're moving the mouse- fast or slow.
Once you detect that the mouse button has been released, draw the rectangle at the final MouseX and MouseY location and THEN start detecting collision again.
If you want the rectangle to "follow" the mouse pointer, but move at a constant speed, then you'll have to use a "waypoint" method.
Every loop you'll have to set the destination waypoint for the rectangle to be the MouseX and MouseY, and move the rectangle toward that point at its constant speed.
Since you're still detecting the mouse button is held down, you won't need to check for collision, just keep moving the rectangle toward the mouse pointer, whereever it may be, UNTIL the mouse button is released, and THEN stop updating the waypoint, so the last waypoint will be the mouseX and mouseY when the button was released.
Keep moving the rectangle toward the last waypoint until it reaches that point and THEN start detecting collisions again.
Just set the rectangle's origin point equal to the mouseX and mouseY every loop, and the rectangle will ALWAYS be drawn at the mouse pointer. The rectangle will essentially move at the same speed as you're moving the mouse- fast or slow.
Once you detect that the mouse button has been released, draw the rectangle at the final MouseX and MouseY location and THEN start detecting collision again.
If you want the rectangle to "follow" the mouse pointer, but move at a constant speed, then you'll have to use a "waypoint" method.
Every loop you'll have to set the destination waypoint for the rectangle to be the MouseX and MouseY, and move the rectangle toward that point at its constant speed.
Since you're still detecting the mouse button is held down, you won't need to check for collision, just keep moving the rectangle toward the mouse pointer, whereever it may be, UNTIL the mouse button is released, and THEN stop updating the waypoint, so the last waypoint will be the mouseX and mouseY when the button was released.
Keep moving the rectangle toward the last waypoint until it reaches that point and THEN start detecting collisions again.