Animal,
Just read up from API docs for BoxComponent.getPosition and founfd the following:
HTML Code:
getPosition( [Boolean local] ) : Array
Gets the current XY position of the component's underlying element.
Parameters:
local : Boolean
(optional) If true the element's left and top are returned instead of page XY (defaults to false)
Returns:
Array
The XY position of the element (e.g., [100, 200])
So instead of the code I posted below you could use getPosition(true) and it would work for constrained windows as well.