virtual-tree-canvas 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tree-view-controller.js +24 -6
package/package.json
CHANGED
|
@@ -892,11 +892,10 @@ export class TreeViewController {
|
|
|
892
892
|
}
|
|
893
893
|
|
|
894
894
|
#rebuildRows() {
|
|
895
|
-
const
|
|
896
|
-
const scrollY = this.viewport.scrollY;
|
|
895
|
+
const scrollAnchor = this.#captureScrollAnchor();
|
|
897
896
|
this.rowModel.rebuild();
|
|
898
897
|
this.#syncContentSize();
|
|
899
|
-
this
|
|
898
|
+
this.#restoreScrollAnchor(scrollAnchor);
|
|
900
899
|
this.rebuildCount++;
|
|
901
900
|
}
|
|
902
901
|
|
|
@@ -1149,14 +1148,33 @@ export class TreeViewController {
|
|
|
1149
1148
|
}
|
|
1150
1149
|
|
|
1151
1150
|
#applyWorkerRows(result) {
|
|
1152
|
-
const
|
|
1153
|
-
const scrollY = this.viewport.scrollY;
|
|
1151
|
+
const scrollAnchor = this.#captureScrollAnchor();
|
|
1154
1152
|
this.rowModel.applyRows(result);
|
|
1155
1153
|
this.#syncContentSize();
|
|
1156
|
-
this
|
|
1154
|
+
this.#restoreScrollAnchor(scrollAnchor);
|
|
1157
1155
|
this.rebuildCount++;
|
|
1158
1156
|
}
|
|
1159
1157
|
|
|
1158
|
+
#captureScrollAnchor() {
|
|
1159
|
+
const scrollX = this.viewport.scrollX;
|
|
1160
|
+
const scrollY = this.viewport.scrollY;
|
|
1161
|
+
const rowIndex = Math.max(0, Math.floor(scrollY / this.rowModel.rowHeight));
|
|
1162
|
+
const row = this.rowModel.getRow(rowIndex);
|
|
1163
|
+
if (!row) return { scrollX, scrollY, nodeId: null, offsetY: 0 };
|
|
1164
|
+
return {
|
|
1165
|
+
scrollX,
|
|
1166
|
+
scrollY,
|
|
1167
|
+
nodeId: row.nodeId,
|
|
1168
|
+
offsetY: Math.max(0, scrollY - row.y),
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
#restoreScrollAnchor(anchor) {
|
|
1173
|
+
const row = anchor.nodeId ? this.rowModel.getRowById(anchor.nodeId) : null;
|
|
1174
|
+
const scrollY = row ? row.y + anchor.offsetY : anchor.scrollY;
|
|
1175
|
+
this.viewport.scrollTo(anchor.scrollX, scrollY);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1160
1178
|
#rebuildInspectorModel(focusPath = '') {
|
|
1161
1179
|
if (!this.inspector) return;
|
|
1162
1180
|
const expanded = new Set(this.expansion.model.expanded);
|