normalise starting position to top,left (from e.g. bottom or right)
use offsetParent() for containment rather than parentNode

This seems to be a more practical interpretation rather than assuming
the immediate parent is also the positioning parent.