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