mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat(loras): add drag event callbacks and preview suppression
- Add onDragStart and onDragEnd callbacks to initDrag function - Implement preview suppression during and briefly after strength dragging - Clear preview timer on drag start/end to prevent tooltip conflicts - Update tests to verify drag callbacks are properly triggered This prevents tooltip previews from interfering with drag interactions and provides better control over drag lifecycle events.
This commit is contained in:
@@ -97,10 +97,19 @@ export function handleAllStrengthsDrag(initialStrengths, initialX, event, widget
|
||||
}
|
||||
|
||||
// Function to initialize drag operation
|
||||
export function initDrag(dragEl, name, widget, isClipStrength = false, previewTooltip, renderFunction) {
|
||||
export function initDrag(
|
||||
dragEl,
|
||||
name,
|
||||
widget,
|
||||
isClipStrength = false,
|
||||
previewTooltip,
|
||||
renderFunction,
|
||||
dragCallbacks = {}
|
||||
) {
|
||||
let isDragging = false;
|
||||
let initialX = 0;
|
||||
let initialStrength = 0;
|
||||
const { onDragStart, onDragEnd } = dragCallbacks;
|
||||
|
||||
// Create a drag handler
|
||||
dragEl.addEventListener('mousedown', (e) => {
|
||||
@@ -122,10 +131,14 @@ export function initDrag(dragEl, name, widget, isClipStrength = false, previewTo
|
||||
initialX = e.clientX;
|
||||
initialStrength = isClipStrength ? loraData.clipStrength : loraData.strength;
|
||||
isDragging = true;
|
||||
|
||||
|
||||
// Add class to body to enforce cursor style globally
|
||||
document.body.classList.add('lm-lora-strength-dragging');
|
||||
|
||||
|
||||
if (typeof onDragStart === 'function') {
|
||||
onDragStart();
|
||||
}
|
||||
|
||||
// Prevent text selection during drag
|
||||
e.preventDefault();
|
||||
});
|
||||
@@ -154,6 +167,10 @@ export function initDrag(dragEl, name, widget, isClipStrength = false, previewTo
|
||||
isDragging = false;
|
||||
// Remove the class to restore normal cursor behavior
|
||||
document.body.classList.remove('lm-lora-strength-dragging');
|
||||
|
||||
if (typeof onDragEnd === 'function') {
|
||||
onDragEnd();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user