Fix for positioning when clicking close to edges of document.
And setting hstart and hend to null when clicking cancel.