mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Enhance DuplicatesManager and VirtualScroller to manage virtual scrolling state and improve rendering logic
This commit is contained in:
@@ -317,8 +317,9 @@ export class VirtualScroller {
|
||||
return { start: firstIndex, end: lastIndex };
|
||||
}
|
||||
|
||||
// Update the scheduleRender method to check for disabled state
|
||||
scheduleRender() {
|
||||
if (this.renderScheduled) return;
|
||||
if (this.disabled || this.renderScheduled) return;
|
||||
|
||||
this.renderScheduled = true;
|
||||
requestAnimationFrame(() => {
|
||||
@@ -327,8 +328,9 @@ export class VirtualScroller {
|
||||
});
|
||||
}
|
||||
|
||||
// Update the renderItems method to check for disabled state
|
||||
renderItems() {
|
||||
if (this.items.length === 0 || this.columnsCount === 0) return;
|
||||
if (this.disabled || this.items.length === 0 || this.columnsCount === 0) return;
|
||||
|
||||
const { start, end } = this.getVisibleRange();
|
||||
|
||||
@@ -672,4 +674,44 @@ export class VirtualScroller {
|
||||
timeout = setTimeout(() => func.apply(context, args), wait);
|
||||
};
|
||||
}
|
||||
|
||||
// Add disable method to stop rendering and events
|
||||
disable() {
|
||||
// Detach scroll event listener
|
||||
this.scrollContainer.removeEventListener('scroll', this.scrollHandler);
|
||||
|
||||
// Clear all rendered items from the DOM
|
||||
this.clearRenderedItems();
|
||||
|
||||
// Hide the spacer element
|
||||
if (this.spacerElement) {
|
||||
this.spacerElement.style.display = 'none';
|
||||
}
|
||||
|
||||
// Flag as disabled
|
||||
this.disabled = true;
|
||||
|
||||
console.log('Virtual scroller disabled');
|
||||
}
|
||||
|
||||
// Add enable method to resume rendering and events
|
||||
enable() {
|
||||
if (!this.disabled) return;
|
||||
|
||||
// Reattach scroll event listener
|
||||
this.scrollContainer.addEventListener('scroll', this.scrollHandler);
|
||||
|
||||
// Show the spacer element
|
||||
if (this.spacerElement) {
|
||||
this.spacerElement.style.display = 'block';
|
||||
}
|
||||
|
||||
// Flag as enabled
|
||||
this.disabled = false;
|
||||
|
||||
// Re-render items
|
||||
this.scheduleRender();
|
||||
|
||||
console.log('Virtual scroller enabled');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ export async function initializeInfiniteScroll(pageType = 'loras') {
|
||||
|
||||
// Skip initializing if in duplicates mode (for recipes page)
|
||||
if (pageType === 'recipes' && pageState.duplicatesMode) {
|
||||
console.log('Skipping virtual scroll initialization - duplicates mode is active');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user