mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
Add enableDataWindowing option to VirtualScroller for improved control over data fetching. (Disable data windowing for now)
This commit is contained in:
@@ -14,6 +14,9 @@ export class VirtualScroller {
|
|||||||
this.pageSize = options.pageSize || 100;
|
this.pageSize = options.pageSize || 100;
|
||||||
this.itemAspectRatio = 896/1152; // Aspect ratio of cards
|
this.itemAspectRatio = 896/1152; // Aspect ratio of cards
|
||||||
this.rowGap = options.rowGap || 20; // Add vertical gap between rows (default 20px)
|
this.rowGap = options.rowGap || 20; // Add vertical gap between rows (default 20px)
|
||||||
|
|
||||||
|
// Add data windowing enable/disable flag
|
||||||
|
this.enableDataWindowing = options.enableDataWindowing !== undefined ? options.enableDataWindowing : false;
|
||||||
|
|
||||||
// State
|
// State
|
||||||
this.items = []; // All items metadata
|
this.items = []; // All items metadata
|
||||||
@@ -447,9 +450,8 @@ export class VirtualScroller {
|
|||||||
const { scrollHeight } = this.scrollContainer;
|
const { scrollHeight } = this.scrollContainer;
|
||||||
const scrollRatio = scrollTop / scrollHeight;
|
const scrollRatio = scrollTop / scrollHeight;
|
||||||
|
|
||||||
// If we've jumped to a position that's significantly outside our current window
|
// Only perform data windowing if the feature is enabled
|
||||||
// and we know there are many items, fetch a new data window
|
if (this.enableDataWindowing && this.totalItems > this.windowSize) {
|
||||||
if (this.totalItems > this.windowSize) {
|
|
||||||
const estimatedIndex = Math.floor(scrollRatio * this.totalItems);
|
const estimatedIndex = Math.floor(scrollRatio * this.totalItems);
|
||||||
const currentWindowStart = this.absoluteWindowStart;
|
const currentWindowStart = this.absoluteWindowStart;
|
||||||
const currentWindowEnd = currentWindowStart + this.items.length;
|
const currentWindowEnd = currentWindowStart + this.items.length;
|
||||||
@@ -488,7 +490,9 @@ export class VirtualScroller {
|
|||||||
|
|
||||||
// Method to fetch data for a specific window position
|
// Method to fetch data for a specific window position
|
||||||
async fetchDataWindow(targetIndex) {
|
async fetchDataWindow(targetIndex) {
|
||||||
if (this.fetchingWindow) return;
|
// Skip if data windowing is disabled or already fetching
|
||||||
|
if (!this.enableDataWindowing || this.fetchingWindow) return;
|
||||||
|
|
||||||
this.fetchingWindow = true;
|
this.fetchingWindow = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -534,6 +538,9 @@ export class VirtualScroller {
|
|||||||
|
|
||||||
// Method to slide the data window if we're approaching its edges
|
// Method to slide the data window if we're approaching its edges
|
||||||
async slideDataWindow() {
|
async slideDataWindow() {
|
||||||
|
// Skip if data windowing is disabled
|
||||||
|
if (!this.enableDataWindowing) return;
|
||||||
|
|
||||||
const { start, end } = this.getVisibleRange();
|
const { start, end } = this.getVisibleRange();
|
||||||
const windowStart = this.dataWindow.start;
|
const windowStart = this.dataWindow.start;
|
||||||
const windowEnd = this.dataWindow.end;
|
const windowEnd = this.dataWindow.end;
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ async function initializeVirtualScroll(pageType) {
|
|||||||
createItemFn: createCardFn,
|
createItemFn: createCardFn,
|
||||||
fetchItemsFn: fetchDataFn,
|
fetchItemsFn: fetchDataFn,
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
rowGap: 20
|
rowGap: 20,
|
||||||
|
enableDataWindowing: false // Explicitly set to false to disable data windowing
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize the virtual scroller
|
// Initialize the virtual scroller
|
||||||
|
|||||||
Reference in New Issue
Block a user