1 | export function getOffset(value, min, max) {
|
2 | return (value - min) / (max - min);
|
3 | }
|
4 | export function getDirectionStyle(direction, value, min, max) {
|
5 | var offset = getOffset(value, min, max);
|
6 | var positionStyle = {};
|
7 |
|
8 | switch (direction) {
|
9 | case 'rtl':
|
10 | positionStyle.right = "".concat(offset * 100, "%");
|
11 | positionStyle.transform = 'translateX(50%)';
|
12 | break;
|
13 |
|
14 | case 'btt':
|
15 | positionStyle.bottom = "".concat(offset * 100, "%");
|
16 | positionStyle.transform = 'translateY(50%)';
|
17 | break;
|
18 |
|
19 | case 'ttb':
|
20 | positionStyle.top = "".concat(offset * 100, "%");
|
21 | positionStyle.transform = 'translateY(-50%)';
|
22 | break;
|
23 |
|
24 | default:
|
25 | positionStyle.left = "".concat(offset * 100, "%");
|
26 | positionStyle.transform = 'translateX(-50%)';
|
27 | break;
|
28 | }
|
29 |
|
30 | return positionStyle;
|
31 | }
|
32 |
|
33 |
|
34 | export function getIndex(value, index) {
|
35 | return Array.isArray(value) ? value[index] : value;
|
36 | } |
\ | No newline at end of file |