mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-22 11:21:15 -03:00
Compare commits
4 Commits
00177a06d0
...
23c6863a3a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23c6863a3a | ||
|
|
c0e2578640 | ||
|
|
e3c812367e | ||
|
|
4d239008a6 |
@@ -16,7 +16,9 @@
|
||||
"help": "Hilfe",
|
||||
"add": "Hinzufügen",
|
||||
"close": "Schließen",
|
||||
"menu": "Menü"
|
||||
"menu": "Menü",
|
||||
"remove": "Entfernen",
|
||||
"change": "Ändern"
|
||||
},
|
||||
"status": {
|
||||
"loading": "Wird geladen...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "Notizen erfolgreich gespeichert",
|
||||
"saveFailed": "Fehler beim Speichern der Notizen"
|
||||
"saveFailed": "Fehler beim Speichern der Notizen",
|
||||
"showMore": "Mehr anzeigen",
|
||||
"showLess": "Weniger anzeigen"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "Voreingestellten Parameter hinzufügen...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "Help",
|
||||
"add": "Add",
|
||||
"close": "Close",
|
||||
"menu": "Menu"
|
||||
"menu": "Menu",
|
||||
"remove": "Remove",
|
||||
"change": "Change"
|
||||
},
|
||||
"status": {
|
||||
"loading": "Loading...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "Notes saved successfully",
|
||||
"saveFailed": "Failed to save notes"
|
||||
"saveFailed": "Failed to save notes",
|
||||
"showMore": "Show more",
|
||||
"showLess": "Show less"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "Add preset parameter...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "Ayuda",
|
||||
"add": "Añadir",
|
||||
"close": "Cerrar",
|
||||
"menu": "Menú"
|
||||
"menu": "Menú",
|
||||
"remove": "Eliminar",
|
||||
"change": "Cambiar"
|
||||
},
|
||||
"status": {
|
||||
"loading": "Cargando...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "Notas guardadas exitosamente",
|
||||
"saveFailed": "Error al guardar notas"
|
||||
"saveFailed": "Error al guardar notas",
|
||||
"showMore": "Mostrar más",
|
||||
"showLess": "Mostrar menos"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "Añadir parámetro preestablecido...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "Aide",
|
||||
"add": "Ajouter",
|
||||
"close": "Fermer",
|
||||
"menu": "Menu"
|
||||
"menu": "Menu",
|
||||
"remove": "Supprimer",
|
||||
"change": "Modifier"
|
||||
},
|
||||
"status": {
|
||||
"loading": "Chargement...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "Notes sauvegardées avec succès",
|
||||
"saveFailed": "Échec de la sauvegarde des notes"
|
||||
"saveFailed": "Échec de la sauvegarde des notes",
|
||||
"showMore": "Afficher plus",
|
||||
"showLess": "Afficher moins"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "Ajouter un paramètre prédéfini...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "עזרה",
|
||||
"add": "הוספה",
|
||||
"close": "סגור",
|
||||
"menu": "תפריט"
|
||||
"menu": "תפריט",
|
||||
"remove": "הסר",
|
||||
"change": "שנה"
|
||||
},
|
||||
"status": {
|
||||
"loading": "טוען...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "הערות נשמרו בהצלחה",
|
||||
"saveFailed": "שמירת ההערות נכשלה"
|
||||
"saveFailed": "שמירת ההערות נכשלה",
|
||||
"showMore": "הצג עוד",
|
||||
"showLess": "הצג פחות"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "הוסף פרמטר קבוע מראש...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "ヘルプ",
|
||||
"add": "追加",
|
||||
"close": "閉じる",
|
||||
"menu": "メニュー"
|
||||
"menu": "メニュー",
|
||||
"remove": "削除",
|
||||
"change": "変更"
|
||||
},
|
||||
"status": {
|
||||
"loading": "読み込み中...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "メモが正常に保存されました",
|
||||
"saveFailed": "メモの保存に失敗しました"
|
||||
"saveFailed": "メモの保存に失敗しました",
|
||||
"showMore": "もっと見る",
|
||||
"showLess": "折りたたむ"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "プリセットパラメータを追加...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "도움말",
|
||||
"add": "추가",
|
||||
"close": "닫기",
|
||||
"menu": "메뉴"
|
||||
"menu": "메뉴",
|
||||
"remove": "제거",
|
||||
"change": "변경"
|
||||
},
|
||||
"status": {
|
||||
"loading": "로딩 중...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "메모가 성공적으로 저장됨",
|
||||
"saveFailed": "메모 저장 실패"
|
||||
"saveFailed": "메모 저장 실패",
|
||||
"showMore": "더 보기",
|
||||
"showLess": "접기"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "프리셋 매개변수 추가...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "Справка",
|
||||
"add": "Добавить",
|
||||
"close": "Закрыть",
|
||||
"menu": "Меню"
|
||||
"menu": "Меню",
|
||||
"remove": "Удалить",
|
||||
"change": "Изменить"
|
||||
},
|
||||
"status": {
|
||||
"loading": "Загрузка...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "Заметки успешно сохранены",
|
||||
"saveFailed": "Не удалось сохранить заметки"
|
||||
"saveFailed": "Не удалось сохранить заметки",
|
||||
"showMore": "Показать больше",
|
||||
"showLess": "Свернуть"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "Добавить предустановленный параметр...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "帮助",
|
||||
"add": "添加",
|
||||
"close": "关闭",
|
||||
"menu": "菜单"
|
||||
"menu": "菜单",
|
||||
"remove": "移除",
|
||||
"change": "更换"
|
||||
},
|
||||
"status": {
|
||||
"loading": "加载中...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "备注保存成功",
|
||||
"saveFailed": "备注保存失败"
|
||||
"saveFailed": "备注保存失败",
|
||||
"showMore": "展开",
|
||||
"showLess": "收起"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "添加预设参数...",
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
"help": "說明",
|
||||
"add": "新增",
|
||||
"close": "關閉",
|
||||
"menu": "選單"
|
||||
"menu": "選單",
|
||||
"remove": "移除",
|
||||
"change": "更換"
|
||||
},
|
||||
"status": {
|
||||
"loading": "載入中...",
|
||||
@@ -1225,7 +1227,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"saved": "備註已儲存",
|
||||
"saveFailed": "儲存備註失敗"
|
||||
"saveFailed": "儲存備註失敗",
|
||||
"showMore": "展開",
|
||||
"showLess": "收起"
|
||||
},
|
||||
"usageTips": {
|
||||
"addPresetParameter": "新增預設參數...",
|
||||
|
||||
@@ -2016,10 +2016,21 @@ class ModelUpdateHandler:
|
||||
self._logger.error("Failed to refresh model updates: %s", exc, exc_info=True)
|
||||
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
||||
|
||||
hide_early_access = False
|
||||
if self._settings is not None:
|
||||
try:
|
||||
hide_early_access = bool(
|
||||
self._settings.get("hide_early_access_updates", False)
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
serialized_records = []
|
||||
for record in records.values():
|
||||
has_update_fn = getattr(record, "has_update", None)
|
||||
if callable(has_update_fn) and has_update_fn():
|
||||
if callable(has_update_fn) and has_update_fn(
|
||||
hide_early_access=hide_early_access
|
||||
):
|
||||
serialized_records.append(self._serialize_record(record))
|
||||
|
||||
return web.json_response(
|
||||
|
||||
@@ -140,14 +140,66 @@
|
||||
|
||||
/* Add specific styles for notes content */
|
||||
.info-item.notes .editable-field [contenteditable] {
|
||||
height: 60px; /* Keep initial modal layout stable regardless of note length */
|
||||
min-height: 60px; /* Increase height for multiple lines */
|
||||
max-height: 420px; /* Limit maximum height */
|
||||
overflow: auto; /* Enable scrolling and resize handle for long content */
|
||||
resize: vertical; /* Allow manual vertical resizing */
|
||||
white-space: pre-wrap; /* Preserve line breaks */
|
||||
line-height: 1.5; /* Improve readability */
|
||||
padding: 8px 12px; /* Slightly increase padding */
|
||||
min-height: 60px;
|
||||
white-space: pre-wrap;
|
||||
line-height: 1.5;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
/* Notes expand/collapse — collapsed by default; only applies when JS detects long content */
|
||||
.info-item.notes .editable-field {
|
||||
position: relative;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.info-item.notes .editable-field.collapsed {
|
||||
max-height: 80px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Gradient fade overlay hint when collapsed */
|
||||
.info-item.notes .editable-field.collapsed::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 28px;
|
||||
background: linear-gradient(transparent, var(--bg-color));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Notes header row — label left, toggle button right */
|
||||
.notes-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* Toggle button — icon only, inline with the label */
|
||||
.notes-toggle-btn {
|
||||
display: none; /* shown by JS when content exceeds threshold */
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--lora-accent);
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background 0.15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.notes-toggle-btn:hover {
|
||||
background: rgba(66, 153, 225, 0.1);
|
||||
}
|
||||
|
||||
.notes-toggle-btn i {
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.file-path {
|
||||
|
||||
@@ -739,7 +739,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #e74c3c;
|
||||
color: var(--lora-error);
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@
|
||||
}
|
||||
|
||||
.batch-preview-error-text {
|
||||
color: #e74c3c;
|
||||
color: var(--lora-error);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@ -798,7 +798,7 @@
|
||||
|
||||
.batch-preview-remove:hover {
|
||||
opacity: 1;
|
||||
color: #e74c3c;
|
||||
color: var(--lora-error);
|
||||
}
|
||||
|
||||
.batch-preview-error {
|
||||
|
||||
@@ -510,7 +510,12 @@ export async function showModelModal(model, modelType) {
|
||||
</div>
|
||||
${typeSpecificContent}
|
||||
<div class="info-item notes">
|
||||
<div class="notes-header">
|
||||
<label>${translate('modals.model.metadata.additionalNotes', {}, 'Additional Notes')} <i class="fas fa-info-circle notes-hint" title="${translate('modals.model.metadata.notesHint', {}, 'Press Enter to save, Shift+Enter for new line')}"></i></label>
|
||||
<button class="notes-toggle-btn" style="display:none" title="${translate('modals.model.notes.showMore', {}, 'Show more')}">
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="editable-field">
|
||||
<div class="notes-content" contenteditable="true" spellcheck="false">${modelWithFullData.notes || translate('modals.model.metadata.addNotesPlaceholder', {}, 'Add your notes here...')}</div>
|
||||
</div>
|
||||
@@ -837,12 +842,70 @@ function setupEditableFields(filePath, modelType) {
|
||||
});
|
||||
}
|
||||
|
||||
// Setup adaptive expand/collapse for notes
|
||||
setupNotesExpand();
|
||||
|
||||
// LoRA specific field setup
|
||||
if (modelType === 'loras') {
|
||||
setupLoraSpecificFields(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adaptive expand/collapse for the Additional Notes section.
|
||||
* Measures content height synchronously after render (before first paint,
|
||||
* so no visual flash). If notes fit within ~4 lines, no toggle is shown.
|
||||
* If they exceed the threshold, the field collapses with a gradient fade
|
||||
* and a "Show more" button appears.
|
||||
*/
|
||||
function setupNotesExpand() {
|
||||
const notesContainer = document.querySelector('.info-item.notes');
|
||||
if (!notesContainer) return;
|
||||
|
||||
const notesField = notesContainer.querySelector('.editable-field');
|
||||
const notesContent = notesContainer.querySelector('.notes-content');
|
||||
const toggleBtn = notesContainer.querySelector('.notes-toggle-btn');
|
||||
|
||||
if (!notesField || !notesContent || !toggleBtn) return;
|
||||
|
||||
const placeholderText = translate('modals.model.metadata.addNotesPlaceholder', {}, 'Add your notes here...');
|
||||
const content = notesContent.textContent || '';
|
||||
const isEmpty = !content.trim() || content === placeholderText;
|
||||
|
||||
if (isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
// CSS default has no constraints, so scrollHeight reflects full content
|
||||
const contentHeight = notesContent.scrollHeight;
|
||||
const collapsedThreshold = 95; // ~4 lines
|
||||
|
||||
if (contentHeight <= collapsedThreshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Long content — collapse and show toggle
|
||||
notesField.classList.add('collapsed');
|
||||
toggleBtn.style.display = 'inline-flex';
|
||||
toggleBtn.title = translate('modals.model.notes.showMore', {}, 'Show more');
|
||||
|
||||
const toggleIcon = toggleBtn.querySelector('i');
|
||||
|
||||
toggleBtn.addEventListener('click', function onClick() {
|
||||
const isCollapsed = notesField.classList.contains('collapsed');
|
||||
if (isCollapsed) {
|
||||
notesField.classList.remove('collapsed');
|
||||
toggleBtn.title = translate('modals.model.notes.showLess', {}, 'Show less');
|
||||
toggleIcon.className = 'fas fa-chevron-up';
|
||||
notesField.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
} else {
|
||||
notesField.classList.add('collapsed');
|
||||
toggleBtn.title = translate('modals.model.notes.showMore', {}, 'Show more');
|
||||
toggleIcon.className = 'fas fa-chevron-down';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupLoraSpecificFields(filePath) {
|
||||
const presetSelector = document.getElementById('preset-selector');
|
||||
const presetValue = document.getElementById('preset-value');
|
||||
|
||||
@@ -11,10 +11,10 @@ import {
|
||||
EMPTY_CONTAINER_HEIGHT
|
||||
} from "./loras_widget_utils.js";
|
||||
import { initDrag, createContextMenu, initHeaderDrag, initReorderDrag, handleKeyboardNavigation } from "./loras_widget_events.js";
|
||||
import { forwardMiddleMouseToCanvas, forwardWheelToCanvas } from "./utils.js";
|
||||
import { forwardMiddleMouseToCanvas, forwardWheelToCanvas, enableListWheelScroll } from "./utils.js";
|
||||
import { PreviewTooltip } from "./preview_tooltip.js";
|
||||
import { ensureLmStyles } from "./lm_styles_loader.js";
|
||||
import { getStrengthStepPreference } from "./settings.js";
|
||||
import { getStrengthStepPreference, getLoraWidgetMaxVisibleLoras } from "./settings.js";
|
||||
|
||||
export function addLorasWidget(node, name, opts, callback) {
|
||||
ensureLmStyles();
|
||||
@@ -29,6 +29,20 @@ export function addLorasWidget(node, name, opts, callback) {
|
||||
// Set initial height using CSS variables approach
|
||||
const defaultHeight = 200;
|
||||
|
||||
// In Vue/node-2.0 mode, cap the widget height so it shows at most N entries.
|
||||
// This prevents content from driving the node size beyond the cap.
|
||||
// canvas/legacy mode is unaffected.
|
||||
if (typeof LiteGraph !== 'undefined' && LiteGraph.vueNodesMode) {
|
||||
const maxLoras = getLoraWidgetMaxVisibleLoras();
|
||||
const gap = 5; // flex gap from .lm-loras-container CSS
|
||||
const maxH = CONTAINER_PADDING + HEADER_HEIGHT + maxLoras * LORA_ENTRY_HEIGHT + maxLoras * gap;
|
||||
container.style.maxHeight = `${maxH}px`;
|
||||
container.style.setProperty('--comfy-widget-max-height', `${maxH}px`);
|
||||
// Window capture-phase hook: scroll the widget instead of zooming the canvas
|
||||
// when the wheel is over a scrollable loras list.
|
||||
enableListWheelScroll(container);
|
||||
}
|
||||
|
||||
// Check if this is a randomizer node (lock button instead of drag handle)
|
||||
const isRandomizerNode = opts?.isRandomizerNode === true;
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@ const NEW_TAB_ZOOM_LEVEL = 0.8;
|
||||
const STRENGTH_STEP_SETTING_ID = "loramanager.strength_step";
|
||||
const STRENGTH_STEP_DEFAULT = 0.05;
|
||||
|
||||
const LORA_WIDGET_MAX_VISIBLE_SETTING_ID = "loramanager.lora_widget_max_visible_loras";
|
||||
const LORA_WIDGET_MAX_VISIBLE_DEFAULT = 12;
|
||||
|
||||
// ============================================================================
|
||||
// Helper Functions
|
||||
// ============================================================================
|
||||
@@ -360,6 +363,32 @@ const getStrengthStepPreference = (() => {
|
||||
};
|
||||
})();
|
||||
|
||||
const getLoraWidgetMaxVisibleLoras = (() => {
|
||||
let settingsUnavailableLogged = false;
|
||||
|
||||
return () => {
|
||||
const settingManager = app?.extensionManager?.setting;
|
||||
if (!settingManager || typeof settingManager.get !== "function") {
|
||||
if (!settingsUnavailableLogged) {
|
||||
console.warn("LoRA Manager: settings API unavailable, using default max visible loras.");
|
||||
settingsUnavailableLogged = true;
|
||||
}
|
||||
return LORA_WIDGET_MAX_VISIBLE_DEFAULT;
|
||||
}
|
||||
|
||||
try {
|
||||
const value = settingManager.get(LORA_WIDGET_MAX_VISIBLE_SETTING_ID);
|
||||
return value ?? LORA_WIDGET_MAX_VISIBLE_DEFAULT;
|
||||
} catch (error) {
|
||||
if (!settingsUnavailableLogged) {
|
||||
console.warn("LoRA Manager: unable to read max visible loras setting, using default.", error);
|
||||
settingsUnavailableLogged = true;
|
||||
}
|
||||
return LORA_WIDGET_MAX_VISIBLE_DEFAULT;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
// ============================================================================
|
||||
// Register Extension with All Settings
|
||||
// ============================================================================
|
||||
@@ -463,6 +492,19 @@ app.registerExtension({
|
||||
tooltip: "Step size for adjusting LoRA strength via arrow buttons or keyboard (default: 0.05)",
|
||||
category: ["LoRA Manager", "LoRA Widget", "Strength Step"],
|
||||
},
|
||||
{
|
||||
id: LORA_WIDGET_MAX_VISIBLE_SETTING_ID,
|
||||
name: "Node 2.0: Maximum visible LoRA entries",
|
||||
type: "slider",
|
||||
attrs: {
|
||||
min: 3,
|
||||
max: 50,
|
||||
step: 1,
|
||||
},
|
||||
defaultValue: LORA_WIDGET_MAX_VISIBLE_DEFAULT,
|
||||
tooltip: "When using Node 2.0 rendering, limit the loras widget height to show at most this many entries (default: 12). Excess entries are accessible via scrollbar.",
|
||||
category: ["LoRA Manager", "LoRA Widget", "Max Visible"],
|
||||
},
|
||||
],
|
||||
async setup() {
|
||||
await loadWorkflowOptions();
|
||||
@@ -549,4 +591,5 @@ export {
|
||||
getUsageStatisticsPreference,
|
||||
getNewTabTemplatePreference,
|
||||
getStrengthStepPreference,
|
||||
getLoraWidgetMaxVisibleLoras,
|
||||
};
|
||||
|
||||
@@ -784,6 +784,51 @@ export function forwardWheelToCanvas(container, options = {}) {
|
||||
}, { passive: false });
|
||||
}
|
||||
|
||||
// Marks scrollable containers whose wheel scrolling must win over canvas zoom.
|
||||
const LM_WHEEL_CLASS = 'lm-wheel-scrollable';
|
||||
let lmWheelHookInstalled = false;
|
||||
|
||||
/**
|
||||
* Keep vertical wheel scrolling inside a scrollable widget container, even in
|
||||
* Nodes 2.0 / Vue mode where ComfyUI's wheel→zoom handler runs on the document
|
||||
* in the capture phase (outer than any container-level listener).
|
||||
* Installs a single capture-phase hook on `window` (the outermost dispatch
|
||||
* point). When the wheel is over a marked, scrollable element, we manually
|
||||
* scroll it and fully consume the event so canvas zoom never sees it.
|
||||
*/
|
||||
export function enableListWheelScroll(container) {
|
||||
if (!container) return;
|
||||
container.classList.add(LM_WHEEL_CLASS);
|
||||
|
||||
if (lmWheelHookInstalled) return;
|
||||
lmWheelHookInstalled = true;
|
||||
|
||||
window.addEventListener('wheel', (event) => {
|
||||
// Let pinch/zoom and horizontal gestures pass through.
|
||||
if (event.ctrlKey) return;
|
||||
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) return;
|
||||
|
||||
const target = event.target;
|
||||
if (!target || typeof target.closest !== 'function') return;
|
||||
const el = target.closest(`.${LM_WHEEL_CLASS}`);
|
||||
if (!el) return;
|
||||
|
||||
const canScrollY = el.scrollHeight > el.clientHeight + 1;
|
||||
if (!canScrollY) return;
|
||||
|
||||
// Translate deltaMode to approximate pixels.
|
||||
const unit = event.deltaMode === 1 ? 16
|
||||
: event.deltaMode === 2 ? el.clientHeight
|
||||
: 1;
|
||||
|
||||
el.scrollTop += event.deltaY * unit;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.stopImmediatePropagation();
|
||||
}, { capture: true, passive: false });
|
||||
}
|
||||
|
||||
// Get connected Lora Pool node from pool_config input
|
||||
export function getConnectedPoolConfigNode(node) {
|
||||
if (!node?.inputs) {
|
||||
|
||||
Reference in New Issue
Block a user