MCPcopy
hub / github.com/react-component/slider / getDirectionStyle

Function getDirectionStyle

src/util.ts:7–35  ·  view source on GitHub ↗
(direction: Direction, value: number, min: number, max: number)

Source from the content-addressed store, hash-verified

5}
6
7export 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 */
38export function getIndex<T>(value: T | T[], index: number) {

Callers 3

Handle.tsxFile · 0.90
DotFunction · 0.90
MarkFunction · 0.90

Calls 1

getOffsetFunction · 0.85

Tested by

no test coverage detected