mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 01:14:50 +08:00
修复表格滚动样式和交互
This commit is contained in:
+1
-1
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user