MCPcopy
hub / github.com/simstudioai/sim / getVisibleCanvasCenter

Function getVisibleCanvasCenter

apps/sim/hooks/use-canvas-viewport.ts:75–87  ·  view source on GitHub ↗

* Gets the center of the visible canvas in screen coordinates.

(options?: CanvasViewportOptions)

Source from the content-addressed store, hash-verified

73 * Gets the center of the visible canvas in screen coordinates.
74 */
75function getVisibleCanvasCenter(options?: CanvasViewportOptions): { x: number; y: number } {
76 const bounds = getVisibleCanvasBounds(options)
77
78 const flowContainer = document.querySelector('.react-flow')
79 const rect = flowContainer?.getBoundingClientRect()
80 const containerLeft = rect?.left ?? 0
81 const containerTop = rect?.top ?? 0
82
83 return {
84 x: containerLeft + bounds.offsetLeft + bounds.width / 2,
85 y: containerTop + bounds.height / 2,
86 }
87}
88
89interface FitViewToBoundsOptions {
90 padding?: number

Callers 1

useCanvasViewportFunction · 0.85

Calls 1

getVisibleCanvasBoundsFunction · 0.85

Tested by

no test coverage detected