@@ -56,18 +56,30 @@ const centerOfBoundsFromBounds = (flow, axis, boundsTo, boundsFrom) => (
5656
5757const place = ( flow , axis , align , bounds , size ) => {
5858 const axisProps = axes [ flow ] [ axis ]
59- return (
60- align === `center`
61- ? centerOfBounds ( flow , axis , bounds ) - centerOfSize ( flow , axis , size )
62- : align === `end`
63- ? bounds [ axisProps . end ]
64- : align === `start`
65- /* DOM rendering unfolds leftward. Therefore if the slave is positioned before
66- the master then the slave`s position must in addition be pulled back
67- by its [the slave`s] own length. */
68- ? bounds [ axisProps . start ] - size [ axisProps . size ]
69- : null
70- )
59+ if ( axis === `main` ) {
60+ return (
61+ align === `center`
62+ ? centerOfBounds ( flow , axis , bounds ) - centerOfSize ( flow , axis , size )
63+ : align === `end`
64+ ? bounds [ axisProps . end ]
65+ : align === `start`
66+ /* DOM rendering unfolds leftward. Therefore if the slave is positioned before
67+ the master then the slave`s position must in addition be pulled back
68+ by its [the slave`s] own length. */
69+ ? bounds [ axisProps . start ] - size [ axisProps . size ]
70+ : null
71+ )
72+ } else {
73+ return (
74+ align === `center`
75+ ? centerOfBounds ( flow , axis , bounds ) - centerOfSize ( flow , axis , size )
76+ : align === `end`
77+ ? bounds [ axisProps . end ]
78+ : align === `start`
79+ ? bounds [ axisProps . start ]
80+ : null
81+ )
82+ }
7183}
7284
7385
@@ -208,13 +220,12 @@ const pickZone = (opts, frameBounds, targetBounds, size) => {
208220
209221/* TODO Document this. */
210222
211- const calcRelPos = ( zone , masterBounds , slaveSize ) => {
223+ const calcRelPos = ( zone , masterBounds , slaveSize , align ) => {
212224 const { main, cross } = axes [ zone . flow ]
213225 /* TODO: The slave is hard-coded to align cross-center with master. */
214- const crossAlign = `center`
215226 const mainStart = place ( zone . flow , `main` , zone . side , masterBounds , slaveSize )
216227 const mainSize = slaveSize [ main . size ]
217- const crossStart = place ( zone . flow , `cross` , crossAlign , masterBounds , slaveSize )
228+ const crossStart = place ( zone . flow , `cross` , align , masterBounds , slaveSize )
218229 const crossSize = slaveSize [ cross . size ]
219230
220231 return {
0 commit comments