- We can fix the deficiency of the previous example by adding
variables xdiff and ydiff which hold the difference,
in pixels, between the mouse pressed position and the origin of the
image. Then xdiff and ydiff are added to the mouse
position, wherever it drags the image - the result is a smooth and
predictable dragging behavior.