(direction: Direction, value: number, min: number, max: number)
| 5 | } |
| 6 | |
| 7 | export function getDirectionStyle(direction: Direction, value: number, min: number, max: number) { |
| 8 | const offset = getOffset(value, min, max); |
| 9 | |
| 10 | const positionStyle: React.CSSProperties = {}; |
| 11 | |
| 12 | switch (direction) { |
| 13 | case 'rtl': |
| 14 | positionStyle.right = `${offset * 100}%`; |
| 15 | positionStyle.transform = 'translateX(50%)'; |
| 16 | break; |
| 17 | |
| 18 | case 'btt': |
| 19 | positionStyle.bottom = `${offset * 100}%`; |
| 20 | positionStyle.transform = 'translateY(50%)'; |
| 21 | break; |
| 22 | |
| 23 | case 'ttb': |
| 24 | positionStyle.top = `${offset * 100}%`; |
| 25 | positionStyle.transform = 'translateY(-50%)'; |
| 26 | break; |
| 27 | |
| 28 | default: |
| 29 | positionStyle.left = `${offset * 100}%`; |
| 30 | positionStyle.transform = 'translateX(-50%)'; |
| 31 | break; |
| 32 | } |
| 33 | |
| 34 | return positionStyle; |
| 35 | } |
| 36 | |
| 37 | /** Return index value if is list or return value directly */ |
| 38 | export function getIndex<T>(value: T | T[], index: number) { |
no test coverage detected