element-plus/packages/components/scrollbar/src/util.ts

30 lines
637 B
TypeScript
Raw Normal View History

import type { CSSProperties } from 'vue'
2020-08-10 15:29:16 +08:00
export const BAR_MAP = {
vertical: {
offset: 'offsetHeight',
scroll: 'scrollTop',
scrollSize: 'scrollHeight',
size: 'height',
key: 'vertical',
axis: 'Y',
client: 'clientY',
direction: 'top',
},
horizontal: {
offset: 'offsetWidth',
scroll: 'scrollLeft',
scrollSize: 'scrollWidth',
size: 'width',
key: 'horizontal',
axis: 'X',
client: 'clientX',
direction: 'left',
},
} as const
2020-08-10 15:29:16 +08:00
export const renderThumbStyle = ({ move, size, bar }): CSSProperties => ({
[bar.size]: size,
transform: `translate${bar.axis}(${move}%)`,
})