MCPcopy
hub / github.com/nilbuild/driver.js / positionArrow

Function positionArrow

tests/popover.test.ts:198–217  ·  view source on GitHub ↗
(opts: {
    side: Side;
    align?: Alignment;
    element: Partial<DOMRect>;
    popover: Partial<DOMRect>;
  })

Source from the content-addressed store, hash-verified

196 // jsdom doesn't lay anything out, so we feed both the element and the popover
197 // their boxes, then refresh to run the positioning against those boxes.
198 function positionArrow(opts: {
199 side: Side;
200 align?: Alignment;
201 element: Partial<DOMRect>;
202 popover: Partial<DOMRect>;
203 }): Promise<void> {
204 const el = document.querySelector<HTMLElement>("#intro")!;
205 el.getBoundingClientRect = () => rect(opts.element);
206 // jsdom has no scrollIntoView; off-screen element boxes would otherwise throw.
207 el.scrollIntoView = () => {};
208
209 const d = createDriver({ animate: false });
210 d.highlight({ element: "#intro", popover: { title: "Intro", side: opts.side, align: opts.align ?? "start" } });
211
212 const wrapper = popoverEl() as HTMLElement;
213 wrapper.getBoundingClientRect = () => rect(opts.popover);
214
215 d.refresh();
216 return nextFrame();
217 }
218
219 it("points the arrow at the element's vertical center for a left/right placement", async () => {
220 // Element sits to the right with its vertical center at y=230; popover box

Callers 1

popover.test.tsFile · 0.85

Calls 4

createDriverFunction · 0.90
popoverElFunction · 0.90
nextFrameFunction · 0.90
rectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…