util.js 719 B

12345678910111213141516171819202122232425262728293031323334
  1. export 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. export function renderThumbStyle({ move, size, bar }) {
  24. const style = {};
  25. const translate = `translate${bar.axis}(${ move }%)`;
  26. style[bar.size] = size;
  27. style.transform = translate;
  28. style.msTransform = translate;
  29. style.webkitTransform = translate;
  30. return style;
  31. };