fix(components): [table] bodyWrapper resized calculate scrollbarStyle (#9149)

* fix(components): [table] tableWrapper resized update scrollbar

* fix(components): [table] Listen to the bodyWrapper

* fix(components): [table] fix max-height

* fix(components): [table] modify scrollbar height error
This commit is contained in:
LIUCHAO
2022-08-25 12:05:31 +08:00
committed by GitHub
parent 43a2c69ad1
commit 1347fdf35a

View File

@@ -200,6 +200,11 @@ function useStyle<T>(
} else {
useEventListener(window, 'resize', resizeListener)
}
useResizeObserver(table.refs.bodyWrapper, () => {
resizeListener()
table.refs?.scrollBarRef?.update()
})
}
const resizeListener = () => {
const el = table.vnode.el
@@ -299,14 +304,14 @@ function useStyle<T>(
}
if (props.maxHeight) {
if (!Number.isNaN(Number(props.maxHeight))) {
const headerHeight = table.refs.headerWrapper?.scrollHeight || 0
const footerHeight = table.refs.footerWrapper?.scrollHeight || 0
const maxHeight = props.maxHeight
const reachMaxHeight = tableScrollHeight.value >= Number(maxHeight)
if (reachMaxHeight) {
return {
maxHeight: `${
tableScrollHeight.value - headerHeight - footerHeight
tableScrollHeight.value -
headerScrollHeight.value -
footerScrollHeight.value
}px`,
}
}