UNPKG

719 BJavaScriptView Raw
1export const BAR_MAP = {
2 vertical: {
3 offset: 'offsetHeight',
4 scroll: 'scrollTop',
5 scrollSize: 'scrollHeight',
6 size: 'height',
7 key: 'vertical',
8 axis: 'Y',
9 client: 'clientY',
10 direction: 'top'
11 },
12 horizontal: {
13 offset: 'offsetWidth',
14 scroll: 'scrollLeft',
15 scrollSize: 'scrollWidth',
16 size: 'width',
17 key: 'horizontal',
18 axis: 'X',
19 client: 'clientX',
20 direction: 'left'
21 }
22};
23
24export function renderThumbStyle({ move, size, bar }) {
25 const style = {};
26 const translate = `translate${bar.axis}(${ move }%)`;
27
28 style[bar.size] = size;
29 style.transform = translate;
30 style.msTransform = translate;
31 style.webkitTransform = translate;
32
33 return style;
34};