MLightCAD
    Preparing search index...

    Function provideViewerRect

    • Creates and provides a reactive viewport rectangle for a viewer host element.

      This function is meant to be called once near the root of a viewer subtree, typically from the main viewer component that owns the container element. It measures the target element with getBoundingClientRect(), keeps the result synchronized as layout changes, and exposes that state to descendants through Vue's dependency injection.

      Synchronization happens in three situations:

      1. When the target element starts existing.
      2. When the target element is resized.
      3. When the browser window is resized.

      Descendants can then consume the provided state with useViewerRect without prop drilling through intermediate components.

      Parameters

      • targetRef: Ref<HTMLElement | undefined>

        Ref pointing at the viewer host element to observe.

      Returns Readonly<
          Ref<
              { height: number; left: number; top: number; width: number },
              { height: number; left: number; top: number; width: number },
          >,
      >

      A readonly reactive ref containing the latest viewer rectangle.