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 = '' | |
9 | ||
10 | if (alignment.includes('top')) { | |
11 | y = 'flex-start'; | |
12 | } else if (alignment.includes('bottom')) { | |
13 | y = 'flex-end'; | |
14 | } else { | |
15 | y = 'center'; | |
16 | } | |
17 | ||
18 | return y; | |
19 | } | |
20 | ||
21 | function setHorizontalContainerAlignment(alignment) { | |
22 | let x = ''; | |
23 | ||
24 | if (alignment.includes('left')) { | |
25 | x = 'flex-start'; | |
26 | } else if (alignment.includes('right')) { | |
27 | x = 'flex-end'; | |
28 | } else { | |
29 | x = 'center'; | |
30 | } | |
31 | ||
32 | return x; | |
33 | } |