Files
element-plus/packages/components/scrollbar/src/util.ts
一只前端汪 7c16480bcd refactor(style): Update Eslint to V9 and Prettier to V3 (#21949)
* refactor(style): Update Eslint to V9 and Prettier to V3

* fix: vscode color

* fix: vscode color

* chore: remove Useless dependence and old config file

* chore: format

* Merge branch 'dev' into eslintV9

* fix: fix

* fix: ssr test

* fix: ssr test

* fix: use defineConfig

* fix: prettier format and ignore docs dist

* fix: index.mjs => index.js

* fix: Vscode color

* fix: prettier ignore global.d.ts

* fix: format

---------

Co-authored-by: 2586740555 <15972343+CYJ090915@user.noreply.gitee.com>
2025-09-29 14:14:30 +08:00

39 lines
831 B
TypeScript

import type { CSSProperties } from 'vue'
import type { ThumbProps } from './thumb'
export const GAP = 4 // top 2 + bottom 2 of bar instance
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
export const renderThumbStyle = ({
move,
size,
bar,
}: Pick<ThumbProps, 'move' | 'size'> & {
bar: (typeof BAR_MAP)[keyof typeof BAR_MAP]
}): CSSProperties => ({
[bar.size]: size,
transform: `translate${bar.axis}(${move}%)`,
})