mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-07-02 12:49:40 +08:00
fixed row height with lib API
This commit is contained in:
parent
ae0e901a2a
commit
0f3becad2d
@ -613,8 +613,6 @@ export class CustomNodesManager {
|
|||||||
const container = this.element.querySelector(".cn-manager-grid");
|
const container = this.element.querySelector(".cn-manager-grid");
|
||||||
const grid = new TG.Grid(container);
|
const grid = new TG.Grid(container);
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
|
|
||||||
const autoHeightColumns = ['description', "alternatives"];
|
|
||||||
|
|
||||||
let prevViewRowsLength = 0;
|
let prevViewRowsLength = 0;
|
||||||
grid.bind('onUpdated', (e, d) => {
|
grid.bind('onUpdated', (e, d) => {
|
||||||
@ -625,47 +623,6 @@ export class CustomNodesManager {
|
|||||||
this.showStatus(`${prevViewRowsLength} custom nodes`);
|
this.showStatus(`${prevViewRowsLength} custom nodes`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const visibleRowList = grid.viewport.rows;
|
|
||||||
const rows = [];
|
|
||||||
const heights = [];
|
|
||||||
|
|
||||||
visibleRowList.forEach(function(viewIndex) {
|
|
||||||
// display index after filter is no equal global index
|
|
||||||
const rowItem = grid.getViewRowItem(viewIndex);
|
|
||||||
if (rowItem.rowHeightFixed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const list = autoHeightColumns.map(k => {
|
|
||||||
const cellNode = grid.getCellNode(rowItem, k);
|
|
||||||
if (cellNode) {
|
|
||||||
const div = cellNode.querySelector('.tg-multiline-fixing');
|
|
||||||
// 10px is padding top and bottom
|
|
||||||
const realHeight = Math.max(TG.$(div).height() + 10, grid.options.rowHeight);
|
|
||||||
return realHeight;
|
|
||||||
}
|
|
||||||
}).filter(n => n);
|
|
||||||
|
|
||||||
if (list.length) {
|
|
||||||
rowItem.rowHeightFixed = true;
|
|
||||||
rows.push(rowItem);
|
|
||||||
heights.push(Math.max.apply(null, list));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
if (!rows.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
grid.setRowHeight(rows, heights);
|
|
||||||
});
|
|
||||||
|
|
||||||
grid.bind('onColumnWidthChanged', (e, d) => {
|
|
||||||
if (autoHeightColumns.includes(d.id)) {
|
|
||||||
// reset when column width changed
|
|
||||||
grid.forEachRow(function(row) {
|
|
||||||
row.rowHeightFixed = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
grid.bind('onSelectChanged', (e, changes) => {
|
grid.bind('onSelectChanged', (e, changes) => {
|
||||||
@ -691,10 +648,15 @@ export class CustomNodesManager {
|
|||||||
frozenColumn: 1,
|
frozenColumn: 1,
|
||||||
rowNotFound: "No Results",
|
rowNotFound: "No Results",
|
||||||
|
|
||||||
rowHeight: 30 * 3 + 3 * 4,
|
rowHeight: 40,
|
||||||
bindWindowResize: true,
|
bindWindowResize: true,
|
||||||
bindContainerResize: true,
|
bindContainerResize: true,
|
||||||
|
|
||||||
|
cellResizeObserver: (rowItem, columnItem) => {
|
||||||
|
const autoHeightColumns = ['title', 'installed', 'description', "alternatives"];
|
||||||
|
return autoHeightColumns.includes(columnItem.id)
|
||||||
|
},
|
||||||
|
|
||||||
// updateGrid handler for filter and keywords
|
// updateGrid handler for filter and keywords
|
||||||
rowFilter: (rowItem) => {
|
rowFilter: (rowItem) => {
|
||||||
|
|
||||||
@ -907,9 +869,6 @@ export class CustomNodesManager {
|
|||||||
if (this.grid) {
|
if (this.grid) {
|
||||||
this.grid.update();
|
this.grid.update();
|
||||||
if (this.hasAlternatives()) {
|
if (this.hasAlternatives()) {
|
||||||
this.grid.forEachRow(function(row) {
|
|
||||||
row.rowHeightFixed = false;
|
|
||||||
});
|
|
||||||
this.grid.showColumn("alternatives");
|
this.grid.showColumn("alternatives");
|
||||||
} else {
|
} else {
|
||||||
this.grid.hideColumn("alternatives");
|
this.grid.hideColumn("alternatives");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user