mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-26 17:30:07 +00:00
Reduce input socket hitbox for widgets (#966)
Restores the full left-arrow button click area for widgets. Previously lost ~5 canvas pixels to clicks intercepted by input sockets. Supporting refactors: - Maps concrete node slot impls. to private array, once per frame - Converts slot boundingRect to use absolute canvas pos (same as other elements) - Stores parent node ref in concrete slot classes
This commit is contained in:
@@ -2,12 +2,17 @@ import type { IColorable } from "@/interfaces"
|
||||
|
||||
/**
|
||||
* Converts a plain object to a class instance if it is not already an instance of the class.
|
||||
*
|
||||
* Requires specific constructor signature; first parameter must be the object to convert.
|
||||
* @param cls The class to convert to
|
||||
* @param obj The object to convert
|
||||
* @param args The object to convert, followed by any other constructor arguments
|
||||
* @returns The class instance
|
||||
*/
|
||||
export function toClass<P, C>(cls: new (plain: P) => C, obj: P | C): C {
|
||||
return obj instanceof cls ? obj : new cls(obj as P)
|
||||
export function toClass<P, C extends P, Args extends unknown[]>(
|
||||
cls: new (instance: P, ...args: Args) => C,
|
||||
...args: [P, ...Args]
|
||||
): C {
|
||||
return args[0] instanceof cls ? args[0] : new cls(...args)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user