mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-11 02:20:08 +00:00
Fix init issue
This commit is contained in:
@@ -61,5 +61,18 @@ export function getCanvasRect(): Rect {
|
||||
|
||||
export function getCanvasClientOrigin() {
|
||||
ensureContainer()
|
||||
return { left: x.value || 0, top: y.value || 0 }
|
||||
const el = containerRef.value
|
||||
// VueUse refs can be 0 on first read right after binding
|
||||
// if the element was assigned in the same tick. In that case,
|
||||
// synchronously read from getBoundingClientRect as a fallback
|
||||
// to avoid returning a zero offset during initialization.
|
||||
const lx = x.value || 0
|
||||
const ly = y.value || 0
|
||||
// Also check width/height to distinguish a legitimate (0,0)
|
||||
// from an unmeasured state (all zeros)
|
||||
if (el && lx === 0 && ly === 0 && width.value === 0 && height.value === 0) {
|
||||
const rect = el.getBoundingClientRect()
|
||||
return { left: rect.left, top: rect.top }
|
||||
}
|
||||
return { left: lx, top: ly }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user