mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-09 13:00:53 +01:00
fix another performance issue -- when lines is hidden vismap was set to all true
This commit is contained in:
parent
31d79b8829
commit
874632939d
20
src/main.tsx
20
src/main.tsx
@ -1711,10 +1711,16 @@ class LinesView extends React.Component<{screen : Screen, width : number, lines
|
|||||||
if (linesElem == null) {
|
if (linesElem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (linesElem.offsetParent == null) {
|
||||||
|
return; // handles when parent is set to display:none (is-hidden)
|
||||||
|
}
|
||||||
let lineElemArr = linesElem.querySelectorAll(".line");
|
let lineElemArr = linesElem.querySelectorAll(".line");
|
||||||
if (lineElemArr == null) {
|
if (lineElemArr == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (linesElem.clientHeight == 0) {
|
||||||
|
return; // when linesElem is collapsed (or display:none)
|
||||||
|
}
|
||||||
let containerTop = linesElem.scrollTop - LinesVisiblePadding;
|
let containerTop = linesElem.scrollTop - LinesVisiblePadding;
|
||||||
let containerBot = linesElem.scrollTop + linesElem.clientHeight + LinesVisiblePadding;
|
let containerBot = linesElem.scrollTop + linesElem.clientHeight + LinesVisiblePadding;
|
||||||
let newMap = new Map<string, boolean>();
|
let newMap = new Map<string, boolean>();
|
||||||
@ -1730,6 +1736,7 @@ class LinesView extends React.Component<{screen : Screen, width : number, lines
|
|||||||
if (lineBot >= containerTop && lineBot <= containerBot) {
|
if (lineBot >= containerTop && lineBot <= containerBot) {
|
||||||
isVis = true
|
isVis = true
|
||||||
}
|
}
|
||||||
|
// console.log("line", lineElem.dataset.linenum, "top=" + lineTop, "bot=" + lineTop, isVis);
|
||||||
newMap.set(lineElem.dataset.linenum, isVis);
|
newMap.set(lineElem.dataset.linenum, isVis);
|
||||||
// console.log("setvis", sprintf("%4d %4d-%4d (%4d) %s", lineElem.dataset.linenum, lineTop, lineBot, lineElem.offsetHeight, isVis));
|
// console.log("setvis", sprintf("%4d %4d-%4d (%4d) %s", lineElem.dataset.linenum, lineTop, lineBot, lineElem.offsetHeight, isVis));
|
||||||
}
|
}
|
||||||
@ -1752,6 +1759,19 @@ class LinesView extends React.Component<{screen : Screen, width : number, lines
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printVisMap() : void {
|
||||||
|
let visMap = this.visibleMap;
|
||||||
|
let lines = this.props.lines;
|
||||||
|
let visLines : string[] = [];
|
||||||
|
for (let i=0; i<lines.length; i++) {
|
||||||
|
let linenum = String(lines[i].linenum);
|
||||||
|
if (visMap.get(linenum).get()) {
|
||||||
|
visLines.push(linenum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("vislines", visLines);
|
||||||
|
}
|
||||||
|
|
||||||
restoreAnchorOffset(reason : string) : void {
|
restoreAnchorOffset(reason : string) : void {
|
||||||
let {screen} = this.props;
|
let {screen} = this.props;
|
||||||
let linesElem = this.linesRef.current;
|
let linesElem = this.linesRef.current;
|
||||||
|
Loading…
Reference in New Issue
Block a user