mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 14:06:00 +00:00
debounced reference painting
This commit is contained in:
@@ -1,22 +1,39 @@
|
||||
import { TableInfo } from 'dbgate-types';
|
||||
|
||||
type DesignerTableInfo = TableInfo & { desingerId: string };
|
||||
type DesignerTableInfo = TableInfo & { designerId: string };
|
||||
|
||||
export default class DomTableRef {
|
||||
domTable: Element;
|
||||
domWrapper: Element;
|
||||
table: DesignerTableInfo;
|
||||
designerId: string;
|
||||
domRefs: { [column: string]: Element };
|
||||
|
||||
constructor(table: DesignerTableInfo, domRefs, domWrapper: Element) {
|
||||
this.domTable = domRefs[''];
|
||||
this.domWrapper = domWrapper;
|
||||
this.table = table;
|
||||
this.designerId = table.designerId;
|
||||
this.domRefs = domRefs;
|
||||
}
|
||||
|
||||
getRect() {
|
||||
return this.domTable.getBoundingClientRect();
|
||||
if (!this.domWrapper) return null;
|
||||
if (!this.domTable) return null;
|
||||
|
||||
const wrap = this.domWrapper.getBoundingClientRect();
|
||||
const rect = this.domTable.getBoundingClientRect();
|
||||
return {
|
||||
left: rect.left - wrap.left,
|
||||
top: rect.top - wrap.top,
|
||||
};
|
||||
}
|
||||
|
||||
get designerId() {
|
||||
return this.table.desingerId;
|
||||
getColumnY(columnName: string) {
|
||||
let col = this.domRefs[columnName];
|
||||
if (!col) return null;
|
||||
const rect = col.getBoundingClientRect();
|
||||
const wrap = this.domWrapper.getBoundingClientRect();
|
||||
return (rect.top + rect.bottom) / 2 - wrap.top;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user