SHOW:
|
|
- or go back to the newest paste.
1 | function setContainerAlignment(alignment) { | |
2 | let x = setHorizontalContainerAlignment(alignment) | |
3 | let y = setVerticalContainerAlignment(alignment) | |
4 | return {'justify-content': x, 'align-items': y} | |
5 | } | |
6 | ||
7 | function setVerticalContainerAlignment(alignment) { | |
8 | let y = 'center' | |
9 | ||
10 | if (alignment.includes('top')) { | |
11 | y = 'flex-start'; | |
12 | } else if (alignment.includes('bottom')) { | |
13 | y = 'flex-end'; | |
14 | } | |
15 | ||
16 | return y; | |
17 | } | |
18 | ||
19 | function setHorizontalContainerAlignment(alignment) { | |
20 | let x = 'center'; | |
21 | ||
22 | if (alignment.includes('left')) { | |
23 | x = 'flex-start'; | |
24 | } else if (alignment.includes('right')) { | |
25 | x = 'flex-end'; | |
26 | } | |
27 | ||
28 | return x; | |
29 | } |