MCPcopy
hub / github.com/microsoft/SandDance / constructor

Method constructor

packages/sanddance/src/tooltip.tsx:27–64  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

25 private child: HTMLElement;
26
27 constructor(props: Props) {
28 const renderProps: RenderProps = {
29 cssPrefix: props.cssPrefix,
30 rows: getRows(props.item, props.options),
31 };
32 this.element = renderTooltip(renderProps) as any as HTMLElement;
33 if (this.element) {
34 this.element.style.position = 'absolute';
35 this.child = this.element.firstChild as HTMLElement;
36 document.body.appendChild(this.element);
37 //measure and move as necessary
38 let m = outerSize(this.child);
39 while (m.height > document.documentElement.clientHeight) {
40 const tr = this.child.querySelector('tr:last-child') as HTMLTableRowElement;
41 if (tr) {
42 tr.parentElement.removeChild(tr);
43 } else {
44 break;
45 }
46 m = outerSize(this.child);
47 }
48 if (props.position.clientX + m.width >= document.documentElement.clientWidth) {
49 this.child.style.right = '0';
50 }
51 let moveTop = true;
52 if (props.position.clientY + m.height >= document.documentElement.clientHeight) {
53 if (props.position.clientY - m.height > 0) {
54 this.child.style.bottom = '0';
55 } else {
56 moveTop = false;
57 }
58 }
59 if (moveTop) {
60 this.element.style.top = `${props.position.clientY}px`;
61 }
62 this.element.style.left = `${props.position.clientX}px`;
63 }
64 }
65
66 finalize() {
67 if (this.element) {

Callers

nothing calls this directly

Calls 3

getRowsFunction · 0.70
renderTooltipFunction · 0.70
outerSizeFunction · 0.50

Tested by

no test coverage detected