修复表格滚动样式和交互

This commit is contained in:
hanhh
2021-10-08 22:39:17 +08:00
parent 632514d36e
commit d6ebd2699e
5 changed files with 65 additions and 5 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import { useState, useEffect, useMemo } from 'react';
import browserType from './browser';
import browserType from './index';
export const useCtx = () => {
const [width, setWidth] = useState('100%');
@@ -170,3 +170,38 @@ export default function browserType() {
return result;
}
/**
*
* @param {*} extraHeight ( Number类型,74)
* @param {*} id table时需要制定table的id
*/
export function getTableScroll({
extraHeight,
id,
}: { extraHeight?: number; id?: string } = {}) {
if (typeof extraHeight == 'undefined') {
// 默认底部分页64 + 边距10
extraHeight = 80;
}
let tHeader = null;
if (id) {
tHeader = document.getElementById(id)
? document
.getElementById(id)!
.getElementsByClassName('ant-table-thead')[0]
: null;
} else {
tHeader = document.getElementsByClassName('ant-table-thead')[0];
}
//表格内容距离顶部的距离
let tHeaderBottom = 0;
if (tHeader) {
tHeaderBottom = tHeader.getBoundingClientRect().bottom;
}
//窗体高度-表格内容顶部的高度-表格内容底部的高度
let height = document.body.clientHeight - tHeaderBottom - extraHeight;
return height;
}