Fix position issues caused by calculateHeight: true

Fixes issues #254, #258 and probably #283

When `calculateHeight` is true, `containerSize` was set to the calculated height, rather than the width. 

I refactored the code to avoid the double assignment and assign `containerSize` to height, only for vertical mode (!isH)