MCPcopy Create free account
hub / github.com/microsoft/SandDance / constructor

Method constructor

docs/app/js/sanddance-app.js:10950–10977  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

10948const { Table } = _vegaDeckGl.controls;
10949class Tooltip {
10950 constructor(props){
10951 const renderProps = {
10952 cssPrefix: props.cssPrefix,
10953 rows: getRows(props.item, props.options)
10954 };
10955 this.element = renderTooltip(renderProps);
10956 if (this.element) {
10957 this.element.style.position = "absolute";
10958 this.child = this.element.firstChild;
10959 document.body.appendChild(this.element);
10960 //measure and move as necessary
10961 let m = outerSize(this.child);
10962 while(m.height > document.documentElement.clientHeight){
10963 let tr = this.child.querySelector("tr:last-child");
10964 if (tr) tr.parentElement.removeChild(tr);
10965 else break;
10966 m = outerSize(this.child);
10967 }
10968 if (props.position.clientX + m.width >= document.documentElement.clientWidth) this.child.style.right = "0";
10969 let moveTop = true;
10970 if (props.position.clientY + m.height >= document.documentElement.clientHeight) {
10971 if (props.position.clientY - m.height > 0) this.child.style.bottom = "0";
10972 else moveTop = false;
10973 }
10974 if (moveTop) this.element.style.top = `${props.position.clientY}px`;
10975 this.element.style.left = `${props.position.clientX}px`;
10976 }
10977 }
10978 finalize() {
10979 if (this.element) document.body.removeChild(this.element);
10980 this.element = null;

Callers

nothing calls this directly

Calls 3

getRowsFunction · 0.70
renderTooltipFunction · 0.70
outerSizeFunction · 0.70

Tested by

no test coverage detected