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